Module: Tribe::Actable

Includes:
Workers::Helpers
Included in:
Actor
Defined in:
lib/tribe/actable.rb

Instance Method Summary collapse

Instance Method Details

#alive?Boolean

Returns:

  • (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 deliver_message!(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

#identifierObject



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 message!(dest, command, data = nil)
  event = Tribe::Event.new(command, data, self)

  dest.deliver_event!(event)

  return nil
end

#nameObject



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 deliver_message!(:_perform, block)
end

#shutdown!Object



71
72
73
# File 'lib/tribe/actable.rb', line 71

def shutdown!
  return deliver_message!(:_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, actor_options = {}, spawn_options = {})
  actor_options[:parent] = self

  @_as.children ||= []
  child = nil

  if spawn_options[:no_raise_on_failure]
    begin
      child = klass.new(actor_options)
    rescue Exception => e
      return false
    end
  else
    child = klass.new(actor_options)
  end

  @_as.children << child

  return child
end