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