Sha256: 4e390c818ebd23e0b5f1ec6b1ca8d0348b8ef6671599515b92aef7fcd8d6a234
Contents?: true
Size: 1.17 KB
Versions: 6
Compression:
Stored size: 1.17 KB
Contents
# code: # * George Moschovitis <gm@navel.gr> # # (c) 2002-2003 Navel, all rights reserved. # $Id: array.rb 165 2004-11-18 12:04:04Z gmosx $ require "sync" module G # == 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
6 entries across 6 versions & 2 rubygems
Version | Path |
---|---|
nitro-0.6.0 | lib/glue/array.rb |
nitro-0.5.0 | lib/glue/array.rb |
nitro-0.7.0 | lib/glue/array.rb |
og-0.7.0 | lib/glue/array.rb |
og-0.5.0 | lib/glue/array.rb |
og-0.6.0 | lib/glue/array.rb |