Hi,

Pondering on the producer/consumer model showed by Jim Weirich
in [ruby-talk:04482], I came to 2 points:

1. Repetitive executing of callcc statement should be avoided.
In particular, producer should not use `each' method to deliver
its data.

2. In general case, consumer should have possibility to stop
further processing.

Here's my example, with dramatically increased performance:

# ======================================
# Usage: producer 100, consumer 50

def producer ( limit, consumer )
  i = 0
  return if callcc { |@producer| }
  i += 1
  consumer.call i unless i > limit
end

def consumer ( limit )
  i = callcc { |cc| return cc }
  print "#{i} "
  @producer.call i < limit ? nil : 0
end
# ======================================

But still, I cannot imagine the case when continuations are
_really_ needed.

Sergey

God bless our submariners