class ConcurrentWorker::IPCDuplexChannel
Public Class Methods
new()
click to toggle source
# File lib/concurrent_worker/common.rb, line 47 def initialize @p_pid = Process.pid @p2c = IO.pipe('ASCII-8BIT', 'ASCII-8BIT') @c2p = IO.pipe('ASCII-8BIT', 'ASCII-8BIT') end
Public Instance Methods
choose_io()
click to toggle source
# File lib/concurrent_worker/common.rb, line 53 def choose_io w_pipe, r_pipe = @p_pid == Process.pid ? [@p2c, @c2p] : [@c2p, @p2c] @wio, @rio = w_pipe[1], r_pipe[0] [w_pipe[0], r_pipe[1]].map(&:close) end
close()
click to toggle source
# File lib/concurrent_worker/common.rb, line 73 def close [@wio, @rio].map(&:close) end
recv()
click to toggle source
# File lib/concurrent_worker/common.rb, line 65 def recv begin Marshal.load(@rio) rescue IOError raise StopIteration end end
send(obj)
click to toggle source
# File lib/concurrent_worker/common.rb, line 59 def send(obj) begin Marshal.dump(obj, @wio) end end