Skip to content

Instantly share code, notes, and snippets.

@simonkro
Created May 28, 2013 10:11
Show Gist options
  • Save simonkro/5661785 to your computer and use it in GitHub Desktop.
Save simonkro/5661785 to your computer and use it in GitHub Desktop.
Untested ...
class ThreadSafeWrapper < Delegator
def initialize(obj)
super
@mutex = Mutex.new
end
def method_missing(m, *args, &block)
@mutex.synchronize { super }
end
def __getobj__
@delegate
end
def __setobj__(obj)
@delegate = obj
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment