normandy/examples/channel_directions.rb
2015-12-15 13:50:47 +01:00

21 lines
363 B
Ruby

# https://gobyexample.com/channel-directions
require 'channel'
def ping(pings, msg)
pings = pings.send_only!
pings << msg
end
def pong(pings, pongs)
pings = pings.receive_only!
pongs = pongs.send_only!
msg = pings.recv
pongs << msg
end
pings = Channel.new(1)
pongs = Channel.new(1)
ping(pings, 'passed message')
pong(pings, pongs)
puts pongs.recv