Skip to content

Commit f7f18fe

Browse files
committed
add mutex for bean loading
1 parent 8105829 commit f7f18fe

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/smart_ioc/bean_factory.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ def initialize(bean_definitions_storage, extra_package_contexts)
1212
@singleton_scope = SmartIoC::Scopes::Singleton.new
1313
@prototype_scope = SmartIoC::Scopes::Prototype.new
1414
@thread_scope = SmartIoC::Scopes::Request.new
15-
@semaphore = Mutex.new
1615
end
1716

1817
def clear_scopes

lib/smart_ioc/bean_file_loader.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ class SmartIoC::BeanFileLoader
22
def initialize
33
@loaded_locations = {}
44
@load_proc = Proc.new { |location| load(location) }
5+
@semaphore = Mutex.new
56
end
67

78
def set_load_proc(&block)
@@ -17,7 +18,10 @@ def require_bean(bean_name)
1718
locations.each do |location|
1819
next if @loaded_locations.has_key?(location)
1920
@loaded_locations[location] = true
20-
@load_proc.call(location)
21+
22+
@semaphore.synchronize do
23+
@load_proc.call(location)
24+
end
2125
end
2226

2327
nil

0 commit comments

Comments
 (0)