mirror of
https://github.com/lloeki/normandy.git
synced 2025-12-06 01:54:40 +01:00
18 lines
279 B
Ruby
18 lines
279 B
Ruby
# https://gobyexample.com/channel-directions
|
|
|
|
require 'channel'
|
|
|
|
def ping(pings, msg)
|
|
pings << msg
|
|
end
|
|
|
|
def pong(pings, pongs)
|
|
msg = pings.recv
|
|
pongs << msg
|
|
end
|
|
|
|
pings = Channel.new(1)
|
|
pongs = Channel.new(1)
|
|
ping(pings, 'passed message')
|
|
pong(pings, pongs)
|
|
puts pongs.recv
|