mirror of
https://github.com/lloeki/normandy.git
synced 2025-12-06 10:04:39 +01:00
examples
This commit is contained in:
parent
1921f98e47
commit
5a968ac76c
11 changed files with 219 additions and 0 deletions
18
examples/channel_directions.rb
Normal file
18
examples/channel_directions.rb
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue