Sha256: 6fa53885e7a1f8a369cdb073c1fa24cfdf36793fc49e4df177aab19e3b43e1ca
Contents?: true
Size: 602 Bytes
Versions: 2
Compression:
Stored size: 602 Bytes
Contents
# -*- encoding: binary -*- # :enddoc: require 'thread' class Rainbows::SyncClose def initialize(body) @body = body @mutex = Mutex.new @cv = ConditionVariable.new @mutex.synchronize do yield self @cv.wait(@mutex) end end def respond_to?(m) @body.respond_to?(m) end def to_path @body.to_path end def each(&block) @body.each(&block) end def to_io @body.to_io end # called by the writer thread to wake up the original thread (in #initialize) def close @body.close ensure @mutex.synchronize { @cv.signal } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rainbows-3.0.0 | lib/rainbows/sync_close.rb |
rainbows-2.1.0 | lib/rainbows/sync_close.rb |