Created
December 29, 2010 05:46
-
-
Save igrep/758224 to your computer and use it in GitHub Desktop.
Queue#to_enum( wait_thread )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# vim: set fileencoding=utf-8 : | |
$VERBOSE = true | |
=begin | |
Queue#to_enum | |
=end | |
require 'thread' | |
class Queue | |
def to_enum wait_thread | |
class << self | |
def each &block | |
block[ self.deq ] while wait_thread.alive? | |
block[ self.deq ] until self.empty? | |
end | |
end | |
self.extend Enumerable | |
self | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment