-> P describes a process that waits for a and then behaves like P • Processes can wait for different events simultaneously: (a -> P ⬛ b -> Q) • Lots of interesting stuff, but really geeky.
central primitives used to describe behavior • Channels are used for communications and synchronization between processes • Channels are basically parameterized events
James Max David] 4 5 callcc {|cc| $cc = cc } 6 7 name = names.shift 8 puts name 9 10 $cc.call unless name == "Max" 11 12 # Outputs: 13 # 14 # John 15 # James 16 # Max
3 puts "ping!" 4 sleep 0.2 5 pong.transfer 6 end 7 end 8 9 pong = Fiber.new do 10 while true 11 puts "pong!" 12 sleep 0.2 13 ping.transfer 14 end 15 end 16 17 ping.resume(pong) Never overflows the stack!