Path: | lib/more/facets/synchash.rb |
Last Update: | Mon Jun 01 21:54:17 -0400 2009 |
A thread-safe hash. We use a sync object instead of a mutex, because it is re-entrant. An exclusive lock is needed when writing, a shared lock IS NEEDED when reading.
Uses the delegator pattern to allow for multiple implementations!
hash = SyncHash.new hash = SyncHash.new(Hash.new) # Delegates
This class uses the delegator pattern. However we don‘t use Ruby‘s delegation facilities, they are more general and powerful than we need here (and slower). Instead a custom (but simple) solution is used.
Copyright (c) 2004 George Moschovitis
Ruby License
This module is free software. You may use, modify, and/or redistribute this software under the same terms as Ruby.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.