Created
June 8, 2017 22:23
-
-
Save zanker/447cc9420a26a8432381edc3228f6b0c to your computer and use it in GitHub Desktop.
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
def <<(work) | |
@mutex.synchronize do | |
if @shutdown | |
raise "Unable to add work while shutting down" | |
end | |
@todo << work | |
if @waiting < @todo.size and @spawned < @max | |
spawn_thread | |
end | |
@not_empty.signal | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment