Class: Multiton::InstanceMutex
- Inherits:
-
Hash
- Object
- Hash
- Multiton::InstanceMutex
- Defined in:
- lib/multiton.rb
Overview
Mutex to safely store multiton instances.
Class Method Summary collapse
Instance Method Summary collapse
- #default(arg) ⇒ Object
-
#initialize ⇒ InstanceMutex
constructor
:nodoc:.
- #initialized(arg) ⇒ Object
Constructor Details
#initialize ⇒ InstanceMutex
:nodoc:
156 157 158 |
# File 'lib/multiton.rb', line 156 def initialize @global = Mutex.new end |
Class Method Details
.synchronize ⇒ Object
164 165 166 |
# File 'lib/multiton.rb', line 164 def (DummyMutex = Object.new).synchronize yield end |
Instance Method Details
#default(arg) ⇒ Object
168 169 170 |
# File 'lib/multiton.rb', line 168 def default(arg) @global.synchronize{ fetch(arg){ store(arg, Mutex.new) } } end |
#initialized(arg) ⇒ Object
160 161 162 |
# File 'lib/multiton.rb', line 160 def initialized(arg) store(arg, DummyMutex) end |