module Pione::Util::FreeThreadGenerator
FreeThreadGenerator
provides the function that creates new threads under main thread group. This is useful for escaping threadgroup encloser.
Public Class Methods
generate(&b)
click to toggle source
Generate a thread with the block under default thread group.
# File lib/pione/util/free-thread-generator.rb, line 14 def self.generate(&b) @method_lock.synchronize do @mutex.synchronize do @queue.push(b) @cv_response.wait(@mutex) thread = @__generated__ @__generated__ = nil @cv_bye.signal return thread end end end
Private Class Methods
create_free_thread()
click to toggle source
Start to run a loop for creating threadgroup free thread.
# File lib/pione/util/free-thread-generator.rb, line 30 def self.create_free_thread while true b = @queue.pop @mutex.synchronize do @__generated__ = Thread.new(&b) @cv_response.signal @cv_bye.wait(@mutex) end end end