Class: UringMachine::Actor
Defined Under Namespace
Classes: Stop
Instance Method Summary collapse
- #call(response_mailbox, sym, *a, **k) ⇒ Object
- #cast(sym, *a, **k) ⇒ Object
- #run(machine, target, mailbox) ⇒ Object
- #stop ⇒ Object
Instance Method Details
#call(response_mailbox, sym, *a, **k) ⇒ Object
47 48 49 50 |
# File 'lib/uringmachine/actor.rb', line 47 def call(response_mailbox, sym, *a, **k) @machine.push @mailbox, [:call, response_mailbox, sym, a, k] @machine.shift response_mailbox end |
#cast(sym, *a, **k) ⇒ Object
42 43 44 45 |
# File 'lib/uringmachine/actor.rb', line 42 def cast(sym, *a, **k) @machine.push @mailbox, [:cast, nil, sym, a, k] self end |
#run(machine, target, mailbox) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/uringmachine/actor.rb', line 29 def run(machine, target, mailbox) @machine = machine @target = target @mailbox = mailbox while (msg = machine.shift(mailbox)) (msg) end rescue Stop # stopped ensure @target.teardown if @target.respond_to?(:teardown) end |
#stop ⇒ Object
52 53 54 |
# File 'lib/uringmachine/actor.rb', line 52 def stop @machine.schedule(self, Stop.new) end |