Skip to content

Commit 3fd27ec

Browse files
authored
Merge pull request #9 from vocrsz/mutex_while_bean_loading
add mutex for bean loading
2 parents 8105829 + 261beb7 commit 3fd27ec

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
smart_ioc (0.5.2)
4+
smart_ioc (0.5.3)
55

66
GEM
77
remote: https://rubygems.org/

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

lib/smart_ioc/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module SmartIoC
2-
VERSION = "0.5.2"
2+
VERSION = "0.5.3"
33
end

0 commit comments

Comments
 (0)