Sha256: b68f423c05d79d15429a6b20071aea70d91c5f711e6d8a758d6f09b61d935a26

Contents?: true

Size: 372 Bytes

Versions: 35

Compression:

Stored size: 372 Bytes

Contents

# encoding: utf-8

require 'thread'

class Object
  def synchronize(&block)
    @mutex ||= Mutex.new
    @mutex.synchronize(&block)
  end
end

class ThreadSafeArray < BasicObject
  def initialize
    @mutex = ::Mutex.new
    @array = []
  end

  def method_missing(method, *args, &block)
    @mutex.synchronize do
      @array.send method, *args, &block
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
adhearsion-2.6.4 lib/adhearsion/foundation/thread_safety.rb
adhearsion-2.6.3 lib/adhearsion/foundation/thread_safety.rb
adhearsion-3.0.0.rc1 lib/adhearsion/foundation/thread_safety.rb
adhearsion-3.0.0.beta2 lib/adhearsion/foundation/thread_safety.rb
adhearsion-3.0.0.beta1 lib/adhearsion/foundation/thread_safety.rb
adhearsion-2.6.2 lib/adhearsion/foundation/thread_safety.rb
adhearsion-2.6.1 lib/adhearsion/foundation/thread_safety.rb
adhearsion-2.6.0 lib/adhearsion/foundation/thread_safety.rb
adhearsion-2.5.4 lib/adhearsion/foundation/thread_safety.rb
adhearsion-2.5.3 lib/adhearsion/foundation/thread_safety.rb
adhearsion-2.5.2 lib/adhearsion/foundation/thread_safety.rb
adhearsion-2.5.0 lib/adhearsion/foundation/thread_safety.rb
adhearsion-2.4.0 lib/adhearsion/foundation/thread_safety.rb
adhearsion-2.4.0.beta3 lib/adhearsion/foundation/thread_safety.rb
adhearsion-2.4.0.beta2 lib/adhearsion/foundation/thread_safety.rb
adhearsion-2.4.0.beta1 lib/adhearsion/foundation/thread_safety.rb
adhearsion-2.3.5 lib/adhearsion/foundation/thread_safety.rb
adhearsion-2.3.4 lib/adhearsion/foundation/thread_safety.rb
adhearsion-2.3.3 lib/adhearsion/foundation/thread_safety.rb
adhearsion-2.3.2 lib/adhearsion/foundation/thread_safety.rb