lib/polyphony/extensions/fiber.rb
# Creates and schedules with priority an out-of-band fiber that runs the
# supplied block. If any uncaught exception is raised while the fiber is
# running, it will bubble up to the main thread's main fiber, which will
# also be scheduled with priority. This method is mainly used trapping
# signals (see also the patched `Kernel#trap`)
#
# @param &block [Proc] given block
# @return [void]
Creates and schedules with priority an out-of-band fiber that runs the
supplied block. If any uncaught exception is raised while the fiber is
running, it will bubble up to the main thread's main fiber, which will
also be scheduled with priority. This method is mainly used trapping
signals
Creates and schedules with priority an out - of - band fiber that runs the supplied block . If any uncaught exception is raised while the fiber is running it will bubble up to the main thread ' s main fiber which will also be scheduled with priority . This method is mainly used trapping signals
def schedule_priority_oob_fiber(&block)
      oob_fiber = Fiber.new do
        Fiber.current.setup_raw
        Thread.backend.trace(:unblock, oob_fiber, nil, @caller)
        result = block.call
      rescue Exception => e
        Thread.current.schedule_and_wakeup(Thread.main.main_fiber, e)
        result = e
      ensure
        Thread.backend.trace(:terminate, Fiber.current, result)
        suspend
      end
      prepare_oob_fiber(oob_fiber, block)
      Thread.backend.trace(:spin, oob_fiber, caller)
      oob_fiber.schedule_with_priority(nil)
    end
def schedule_priority_oob_fiber ( & block ) oob_fiber = Fiber . new do Fiber . current . setup_raw Thread . backend . trace ( :unblock , oob_fiber , nil , @caller ) result = block . call rescue Exception => e Thread . current . schedule_and_wakeup ( Thread . main . main_fiber , e ) result = e ensure Thread . backend . trace ( :terminate , Fiber . current , result ) suspend end prepare_oob_fiber ( oob_fiber , block ) Thread . backend . trace ( :spin , oob_fiber , caller ) oob_fiber . schedule_with_priority ( nil ) end
Creates and schedules with priority an out-of-band fiber that runs the
supplied block.
Creates and schedules with priority an out - of - band fiber that runs the supplied block .
None
void
block
<not_specific>
&block
<not_specific>
None