Sha256: 3b359a44ddb4a7bd6961c89c1810d425fed4da3ea4941ed22ade0944b4355978
Contents?: true
Size: 562 Bytes
Versions: 9
Compression:
Stored size: 562 Bytes
Contents
class ThreadSender def initialize @queue = Queue.new @thread = Thread.new{ reaper } end def reaper loop do block, response_queue = *@queue.pop response_queue.push(block.call) end end # If callbacks are invoked within a thread_send, we process them inside the # same thread. # Calling pop on the queue would cause deadlocks. def thread_send if @thread == Thread.current yield else response_queue = Queue.new @queue.push([Proc.new, response_queue]) response_queue.pop end end end
Version data entries
9 entries across 9 versions & 1 rubygems