diff --git a/lib/rom/factory/sequences.rb b/lib/rom/factory/sequences.rb index 9a76ce2..ccaad32 100644 --- a/lib/rom/factory/sequences.rb +++ b/lib/rom/factory/sequences.rb @@ -19,12 +19,15 @@ def self.[](relation) # @api private def initialize + @mutex = Mutex.new reset end # @api private def next(key) - registry[key] += 1 + @mutex.synchronize do + registry[key] += 1 + end end # @api private