class Concurrent::SynchronizedDelegator

@!visibility private
This class is currently being considered for inclusion into stdlib, via
currently on some implementations.
for it, but this is a trivial way to get thread-safety where none may exist
object, in that it will cause synchronization for methods that have no need
A simple ‘Monitor` provides a very coarse-grained way to synchronize a given
array = SynchronizedDelegator.new([]) # thread-safe
array = [] # not thread-safe on many impls
around the delegated `#send`. Example:
by wrapping it with a `Delegator` that performs `Monitor#enter/exit` calls
This class provides a trivial way to synchronize all calls to a given object

def initialize(obj)

def initialize(obj)
  __setobj__(obj)
  @monitor = Monitor.new
end

def method_missing(method, *args, &block)

def method_missing(method, *args, &block)
  monitor = @monitor
  begin
    monitor.enter
    super
  ensure
    monitor.exit
  end
end

def setup

def setup
  @old_abort = Thread.abort_on_exception
  Thread.abort_on_exception = true
end

def teardown

def teardown
  Thread.abort_on_exception = @old_abort
end