Skip to content

Instantly share code, notes, and snippets.

@neektza
Created April 14, 2017 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neektza/0df1ae787ed4f9dff4051fa8fd8518a1 to your computer and use it in GitHub Desktop.
Save neektza/0df1ae787ed4f9dff4051fa8fd8518a1 to your computer and use it in GitHub Desktop.
module EventMachine
def self.spawn_threadpool
until @threadpool.size == @threadpool_size.to_i
thread = Thread.new do
Thread.current.abort_on_exception = true
while true
op, cback = *@threadqueue.pop
result = op.call
@resultqueue << [result, cback]
EventMachine.signal_loopbreak
end
end
@threadpool << thread
end
@all_threads_spawned = true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment