Class: Multiton::InstanceMutex
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
Methods inherited from Hash
#&, #*, #+, #-, #<<, #alias!, #argumentize, autonew, #delete_unless, #delete_values, #delete_values_at, #diff, #each_with_key, #except, #except!, #has_keys?, #has_only_keys?, #insert, #inverse, #join, #mash!, #normalize_keys, #normalize_keys!, #pairs_at, #rand_key, #rand_key!, #rand_pair, #rand_pair!, #rand_value, #rand_value!, #rekey, #rekey!, #replace_each, #restore_snapshot, #reverse_merge, #reverse_merge!, #select!, #shuffle, #shuffle!, #slice, #slice!, #stringify_keys, #stringify_keys!, #swap!, #swapkey!, #symbolize_keys, #symbolize_keys!, #take_snapshot, #to_console, #to_h, #to_openobject, #to_ostruct, #to_ostruct_recurse, #to_proc, #to_proc_with_reponse, #to_struct, #traverse, #traverse!, #update_each, #update_keys, #update_values, #variablize_keys, #variablize_keys!, #weave, zipnew, #|
Constructor Details
#initialize ⇒ InstanceMutex
:nodoc:
127 128 129 |
# File 'lib/more/facets/multiton.rb', line 127 def initialize @global = Mutex.new end |
Class Method Details
Instance Method Details
#default(arg) ⇒ Object
139 140 141 |
# File 'lib/more/facets/multiton.rb', line 139 def default(arg) @global.synchronize{ fetch(arg){ store(arg, Mutex.new) } } end |
#initialized(arg) ⇒ Object
131 132 133 |
# File 'lib/more/facets/multiton.rb', line 131 def initialized(arg) store(arg, DummyMutex) end |