| Class | Dramatis::Actor::Name::Interface |
| In: |
lib/dramatis/actor/name/interface.rb
|
| Parent: | Object |
A Dramatis::Actor::Name::Interface object provides the ability to modify the semantics of actor name and perform other actor-level operations on an actor. It is typically created via Dramatis.interface.
Binds the actor identified by this name to supplied behavior, which should be a native ruby object. Can only be called on unbound actors, typically created with Dramatis::Actor.new(). The result of the call is the actor name of the actor. The continuation semantics of the call depend on the name like a normal actor method call.
# File lib/dramatis/actor/name/interface.rb, line 84
84: def bind behavior
85: actor_send :bind, behavior
86: end
In call cases, returns a new name with the specified continuation semantics.
When passed a nil argument, returns a new actor name with a nil continuation such that when used in an actor method call, the call will return nil immediately. The return value from such a call is lost. Equivalent to and usually called as Dramatis.release.
The second form sets up the block passed to the function as the continuation of the call. When the continuation task is received from the target actor, the block will be executed. From senders point of view, the block is an unnamed method: it will only be scheduled when the actor is not executing any other task.
Currently it is not possible to gate off block continuations.
The third example is a variant on the second and is used to provide a second block to receive an exception object if the actor method call results in an exception being thrown. Otherwise, the runtime will try to deliver exceptions to a dramatis_exception actor method if defined. Otherwise it will be recored by the runtime.
# File lib/dramatis/actor/name/interface.rb, line 44
44: def continue options = {}, &continuation
45: raise "contradictory options passed to continue" \
46: if ( options == nil and continuation ) or
47: ( options and !continuation )
48: a, o = @name.instance_eval { [ @actor, @options ] }
49: @name = Dramatis::Actor::Name.new a
50: @name.instance_eval do
51: @options = o.dup
52: @options[:continuation] = options == nil ? :none : continuation
53: options and @options[:exception] = options[:exception]
54: end
55: @name
56: end
Returns a new actor name that when used in an actor method call will return a Dramatis::Future. Usually called via Dramatis.future rather than directly.
# File lib/dramatis/actor/name/interface.rb, line 64
64: def future
65: a, o = @name.instance_eval { [ @actor, @options ] }
66: @name = Dramatis::Actor::Name.new a
67: @name.instance_eval do
68: @options = o.dup
69: @options[:continuation] = :future
70: end
71: @name
72: end