class Context
Represents the execution context that installed a signal handler set.
Definitions
def self.current
Capture the current execution context.
Signature
-
returns
Context The current execution context.
Implementation
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
def initialize(thread, fiber, scheduler = nil)
Initialize the context.
Signature
-
parameter
threadThread The thread that installed the handler set.
-
parameter
fiberFiber The fiber that installed the handler set.
-
parameter
schedulerObject | Nil The scheduler that can interrupt the fiber.
Implementation
def initialize(thread, fiber, scheduler = nil)
@thread = thread
@fiber = fiber
@scheduler = scheduler
end
def raise(*arguments)
Raise an exception in the execution context that installed the handler set.
Signature
-
parameter
argumentsArray The arguments to pass to
Thread#raise.
Implementation
def raise(*arguments)
if @scheduler
return @scheduler.fiber_interrupt(@fiber, exception_for(arguments))
end
@thread.raise(*arguments)
end