Class: ThreadSafeArray

Inherits:
BasicObject
Defined in:
lib/adhearsion/foundation/thread_safety.rb

Instance Method Summary collapse

Constructor Details

#initializeThreadSafeArray

Returns 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

#method_missing(method, *args, &block) ⇒ Object



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