Sha256: b4d4e5b0eab94b2c042712610b311ec0a995aff4cc7c08e19e29f562117a54a2
Contents?: true
Size: 689 Bytes
Versions: 1
Compression:
Stored size: 689 Bytes
Contents
# frozen_string_literal: true require 'bundler/setup' require 'polyphony' def echo(rchan, wchan) puts "start echoer" while msg = rchan.receive wchan << "you said: #{msg}" end ensure puts "echoer stopped" end chan1, chan2 = Polyphony::Channel.new, Polyphony::Channel.new echoer = spin { echo(chan1, chan2) } spin do puts "start receiver" while msg = chan2.receive puts msg $main.resume if msg =~ /world/ end ensure puts "receiver stopped" end $main = spin do t0 = Time.now puts "send hello" chan1 << "hello" puts "send world" chan1 << "world" suspend puts "closing channels" chan1.close chan2.close puts "done #{Time.now - t0}" end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
polyphony-0.19 | examples/core/channel_echo.rb |