Class: ThreadSafeArray
- Inherits:
- BasicObject
- Defined in:
- lib/adhearsion/foundation/thread_safety.rb
Instance Method Summary (collapse)
-
- (ThreadSafeArray) initialize
constructor
A new instance of ThreadSafeArray.
- - (Object) method_missing(method, *args, &block)
Constructor Details
- (ThreadSafeArray) initialize
A new instance of ThreadSafeArray
13 14 15 16 |
# File 'lib/adhearsion/foundation/thread_safety.rb', line 13 def initialize @mutex = ::Mutex.new @array = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(method, *args, &block)
18 19 20 21 22 |
# File 'lib/adhearsion/foundation/thread_safety.rb', line 18 def method_missing(method, *args, &block) @mutex.synchronize do @array.send method, *args, &block end end |