class Slave::ThreadSafe

ThreadSafe is a delegate wrapper class used for implementing gross thread safety around existing objects. when an object is wrapped with this class as

ts = ThreadSafe.new{ AnyObject.new }

then ts can be used exactly as the normal object would have been, only all calls are now thread safe. this is the mechanism behind the 'threadsafe'/:threadsafe keyword to Slave#initialize

ThreadSafe is a delegate wrapper class used for implementing gross thread safety around existing objects. when an object is wrapped with this class as

ts = ThreadSafe.new{ AnyObject.new }

then ts can be used exactly as the normal object would have been, only all calls are now thread safe. this is the mechanism behind the 'threadsafe'/:threadsafe keyword to Slave#initialize

Public Class Methods

new(object) click to toggle source
# File lib/slave-1.2.1.rb, line 130
def initialize object
  @object = object
  @sync = Sync.new
end

Public Instance Methods

class() click to toggle source
# File lib/slave-1.2.1.rb, line 146
def class
  ex{ @object.class }
end
ex() { || ... } click to toggle source
# File lib/slave-1.2.1.rb, line 134
def ex
  @sync.synchronize{ yield }
end
inspect() click to toggle source
# File lib/slave-1.2.1.rb, line 143
def inspect
  ex{ @object.inspect }
end
method_missing(m, *a, &b) click to toggle source
# File lib/slave-1.2.1.rb, line 137
def method_missing m, *a, &b
  ex{ @object.send m, *a, &b }
end
respond_to?(*a, &b) click to toggle source
# File lib/slave-1.2.1.rb, line 140
def respond_to? *a, &b 
  ex{ @object.respond_to? *a, &b }
end