class Eventbox::ExternalProc
Wrapper for Proc objects created external or in the action scope of some Eventbox
instance.
External Proc objects can be invoked from event scope by {ExternalProc#call}. It can be called within {Eventbox::Boxable#sync_call sync_call} and {Eventbox::Boxable#yield_call yield_call} methods and from {Eventbox#sync_proc} and {Eventbox#yield_proc} closures. The proc then runs in the background on the thread that called the event scope method in execution.
It's also possible to invoke it within a {Eventbox::Boxable#async_call async_call} or {Eventbox#async_proc}, when the method or proc that brought the external proc into the event scope, is a yield call that didn't return yet. In this case the proc runs in the background on the thread that is waiting for the yield call to return.
Optionally a proc can be provided as the last argument which acts as a completion callback. This proc is invoked, when the call has finished, with the result value as argument.
class Callback < Eventbox sync_call def init(&block) # invoke the block given to Callback.new # and when completed, print the result of the block block.call 5, ->(res){ p res } end end Callback.new {|num| num + 1 } # Output: 6
External Proc objects can also be passed to action or to external scope. In this case a {ExternalProc} is unwrapped back to the ordinary Proc object.
@see ExternalObject
Attributes
@private
Public Class Methods
@private
# File lib/eventbox/sanitizer.rb, line 444 def initialize(object, event_loop, name=nil) @object = object @event_loop = event_loop @name = name end
Public Instance Methods
@private
# File lib/eventbox/sanitizer.rb, line 451 def object_for(target_event_loop) @event_loop == target_event_loop ? @object : self end