#!/usr/bin/env ruby require 'coroutine' first = nil second = nil puts "Creating First" first = Coroutine.new { puts "First: Doing some work" first.switch_to(second) puts "First: More work" first.switch_to(second) puts "First: Done" } puts "Creating Second" second = Coroutine.new { puts "Second: Kickin' back" second.switch_to(first) puts "Second: Time for Coffee" second.switch_to(first) puts "Second: Done" } first.start puts "End Of Demo" |
[ Index ][ Table of Contents ] | Generated by [ source2html ] |