rbzmq
rbzmq copied to clipboard
Yield
This patch adds yield to block capability for Contexts and Sockets, cleaning up after the interior of the block exits, just like IO.new(). This allows you to write code such as:
#!/usr/bin/env ruby
require 'zmq'
ZMQ::Context.new do |ctx|
ctx.socket(ZMQ::SUB) do |sock|
sock.bind('ipc:///tmp/zmq.1')
sock.setsockopt(ZMQ::SUBSCRIBE, 'sample')
loop do
msg = sock.recv
puts msg
end
end
end
Cool, can you add a commit that updates the docs as well?
Yes, sorry, will resubmit tomorrow.
On Tue, May 15, 2012 at 3:46 PM, Brian Buchanan < [email protected]
wrote:
Cool, can you add a commit that updates the docs as well?
Reply to this email directly or view it on GitHub: https://github.com/zeromq/rbzmq/pull/20#issuecomment-5725378