Sha256: 555fbd8eb5cab7718ff8707b99064ba637601c6ffa9c062108676438815ce375
Contents?: true
Size: 791 Bytes
Versions: 1
Compression:
Stored size: 791 Bytes
Contents
module Celluloid # An abstraction around threads from the InternalPool which ensures we don't # accidentally do things to threads which have been returned to the pool, # such as, say, killing them class ThreadHandle def initialize @mutex = Mutex.new @join = ConditionVariable.new @thread = InternalPool.get do begin yield ensure @mutex.synchronize do @thread = nil @join.broadcast end end end end def alive? @mutex.synchronize { @thread.alive? if @thread } end def kill !!@mutex.synchronize { @thread.kill if @thread } end def join @mutex.synchronize { @join.wait(@mutex) if @thread } nil end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kulesa-celluloid-0.10.2 | lib/celluloid/thread_handle.rb |