I wrote this ThreadSafeArray class. Seems to work, but I thought I'd throw
it out here for review. Any holes in this approach?
class ThreadSafeArray
def initialize
@mutex = Mutex.new
@internalArray = []
end
def ary
@internalArray
end
def method_missing(method, *args, &block)
@mutex.lock
begin
@internalArray.send(method, *args, &block)
ensure
@mutex.unlock
end
end
end
Chris Morris