Sha256: 46ebad26449f8b803a79629b05cb4ca91df91dcf0d5cdc0b881d2af894cff990
Contents?: true
Size: 707 Bytes
Versions: 3
Compression:
Stored size: 707 Bytes
Contents
require 'thread' module Tork module Client class Receiver < Thread def initialize *popen_args (@io = IO.popen(*popen_args)).sync = true super() { loop { yield @io.gets } } end def quit kill # stop receive loop Process.kill :SIGTERM, @io.pid Process.wait @io.pid # reap zombie @io.close # prevent further I/O end end class Transceiver < Receiver def initialize *popen_args @io_write_lock = Mutex.new popen_args[1] = 'w+' super end def send command @io_write_lock.synchronize do warn "#{caller[2]} SEND #{command.inspect}" if $DEBUG @io.puts JSON.dump(command) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tork-16.0.0 | lib/tork/client.rb |
tork-15.1.0 | lib/tork/client.rb |
tork-15.0.1 | lib/tork/client.rb |