Module: Tribe::Actable
Instance Method Summary collapse
- #alive? ⇒ Boolean
- #deliver_event!(event) ⇒ Object
- #deliver_message!(command, data = nil, src = nil) ⇒ Object
- #future!(dest, command, data = nil) ⇒ Object
- #identifier ⇒ Object
- #message!(dest, command, data = nil) ⇒ Object
- #name ⇒ Object
- #perform!(&block) ⇒ Object
- #shutdown! ⇒ Object
- #spawn(klass, actor_options = {}, spawn_options = {}) ⇒ Object
Instance Method Details
#alive? ⇒ Boolean
100 101 102 |
# File 'lib/tribe/actable.rb', line 100 def alive? @_as.mailbox.alive? end |
#deliver_event!(event) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/tribe/actable.rb', line 40 def deliver_event!(event) @_as.mailbox.push(event) do process_events end return nil end |
#deliver_message!(command, data = nil, src = nil) ⇒ Object
48 49 50 51 52 |
# File 'lib/tribe/actable.rb', line 48 def (command, data = nil, src = nil) deliver_event!(Tribe::Event.new(command, data, src)) return nil end |
#future!(dest, command, data = nil) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/tribe/actable.rb', line 62 def future!(dest, command, data = nil) event = Tribe::Event.new(command, data, self) event.future = future = Tribe::Future.new(self) dest.deliver_event!(event) return future end |
#identifier ⇒ Object
108 109 110 |
# File 'lib/tribe/actable.rb', line 108 def identifier return @_as.name ? "#{object_id}:#{@_as.name}" : object_id end |
#message!(dest, command, data = nil) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/tribe/actable.rb', line 54 def (dest, command, data = nil) event = Tribe::Event.new(command, data, self) dest.deliver_event!(event) return nil end |
#name ⇒ Object
104 105 106 |
# File 'lib/tribe/actable.rb', line 104 def name return @_as.name end |
#perform!(&block) ⇒ Object
75 76 77 |
# File 'lib/tribe/actable.rb', line 75 def perform!(&block) return (:_perform, block) end |
#shutdown! ⇒ Object
71 72 73 |
# File 'lib/tribe/actable.rb', line 71 def shutdown! return (:_shutdown) end |
#spawn(klass, actor_options = {}, spawn_options = {}) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/tribe/actable.rb', line 79 def spawn(klass, = {}, = {}) [:parent] = self @_as.children ||= [] child = nil if [:no_raise_on_failure] begin child = klass.new() rescue Exception => e return false end else child = klass.new() end @_as.children << child return child end |