Skip to content

Instantly share code, notes, and snippets.

@lukaszx0
Created October 18, 2013 09:39
Show Gist options
  • Save lukaszx0/7039115 to your computer and use it in GitHub Desktop.
Save lukaszx0/7039115 to your computer and use it in GitHub Desktop.
class Foobar
def initialize
@data = {}
@lock = Mutex.new
end
def [](key)
@lock do
@data[key.to_s]
end
end
def []=(key, value)
@lock.synchronize do
@data[key.to_s] = value
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment