Read this blog post: SyncEm: Thread-Safe Decorators in Ruby.
Sometimes you have an object that is not thread-safe,
but you need to make sure each of its methods is thread-safe, because they
deal with some resources, like files or databases and you want them to
manage those resources sequentially. This small gem will help you achieve
exactly that without any re-design of the objects you already have. Just
decorate them with
SyncEm thread-safe decorator
and that is it.
First, install it:
$ gem install syncem
Then, use it like this:
require 'syncem' obj = SyncEm.new(obj)
How to contribute
$ bundle update $ bundle exec rake
If it's clean and you don't see any error messages, submit your pull request.