Sha256: 2a4ec6e96f0d838377d508e5703145ed9c37132b668c023e41377fe32b8cd585
Contents?: true
Size: 1.17 KB
Versions: 4
Compression:
Stored size: 1.17 KB
Contents
# code: # * George Moschovitis <gm@navel.gr> # # (c) 2002-2003 Navel, all rights reserved. # $Id: array.rb 202 2005-01-17 10:44:13Z gmosx $ require "sync" module N # == SafeArray # # A thread-safe array. 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 # class SafeArray < Array attr :sync # gmosx: delegator is not used. # def initialize(delegator = nil) @sync = ::Sync.new() end def << (value) return @sync.synchronize(::Sync::SH) { super } end def delete_if(&block) return @sync.synchronize(::Sync::SH) { super } end def [](key) return @sync.synchronize(::Sync::SH) { super } end def []=(key, value) return @sync.synchronize(::Sync::EX) { super } end def delete(key) return @sync.synchronize(::Sync::EX) { super } end def clear @sync.synchronize(::Sync::EX) { super } end def size return @sync.synchronize(::Sync::SH) { super } end def shift return @sync.synchronize(::Sync::EX) { super } end def unshift(el) return @sync.synchronize(::Sync::EX) { super } end end end # module
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
nitro-0.9.5 | lib/glue/array.rb |
nitro-0.9.3 | lib/glue/array.rb |
og-0.9.3 | lib/glue/array.rb |
og-0.9.5 | lib/glue/array.rb |