Class: Async::Signals::Context
- Inherits:
-
Object
- Object
- Async::Signals::Context
- Defined in:
- lib/async/signals/context.rb
Overview
Represents the execution context that installed a signal handler set.
Class Method Summary collapse
-
.current ⇒ Object
Capture the current execution context.
Instance Method Summary collapse
-
#initialize(thread, fiber, scheduler = nil) ⇒ Context
constructor
Initialize the context.
-
#raise(*arguments) ⇒ Object
Raise an exception in the execution context that installed the handler set.
Constructor Details
#initialize(thread, fiber, scheduler = nil) ⇒ Context
Initialize the context.
32 33 34 35 36 |
# File 'lib/async/signals/context.rb', line 32 def initialize(thread, fiber, scheduler = nil) @thread = thread @fiber = fiber @scheduler = scheduler end |
Class Method Details
.current ⇒ Object
Capture the current execution context.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/async/signals/context.rb', line 12 def self.current thread = ::Thread.current fiber = ::Fiber.current scheduler = nil if ::Fiber.respond_to?(:current_scheduler) if current_scheduler = ::Fiber.current_scheduler if current_scheduler.respond_to?(:fiber_interrupt) scheduler = current_scheduler end end end self.new(thread, fiber, scheduler) end |
Instance Method Details
#raise(*arguments) ⇒ Object
Raise an exception in the execution context that installed the handler set.
40 41 42 43 44 45 46 |
# File 'lib/async/signals/context.rb', line 40 def raise(*arguments) if @scheduler return @scheduler.fiber_interrupt(@fiber, exception_for(arguments)) end @thread.raise(*arguments) end |