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)

92
93
94
# File 'lib/tribe/actable.rb', line 92

def alive?
  @_actable.mailbox.alive?
end

#dead?Boolean

Returns:

  • (Boolean)

96
97
98
# File 'lib/tribe/actable.rb', line 96

def dead?
  !alive?
end

#deliver_event!(event) ⇒ Object


46
47
48
49
50
51
52
# File 'lib/tribe/actable.rb', line 46

def deliver_event!(event)
  @_actable.mailbox.push(event) do
    process_events
  end

  nil
end

#direct_message!(command, data = nil, src = nil) ⇒ Object


54
55
56
57
58
# File 'lib/tribe/actable.rb', line 54

def direct_message!(command, data = nil, src = nil)
  deliver_event!(Tribe::Event.new(command, data, src))

  nil
end

#exceptionObject


108
109
110
# File 'lib/tribe/actable.rb', line 108

def exception
  @_actable.exception
end

#identifierObject


104
105
106
# File 'lib/tribe/actable.rb', line 104

def identifier
  @_actable.name ? "#{object_id}:#{@_actable.name}" : object_id
end

#loggerObject


120
121
122
# File 'lib/tribe/actable.rb', line 120

def logger
  @_actable.logger
end

#nameObject


100
101
102
# File 'lib/tribe/actable.rb', line 100

def name
  @_actable.name
end

#perform!(&block) ⇒ Object


64
65
66
# File 'lib/tribe/actable.rb', line 64

def perform!(&block)
  direct_message!(:__perform__, block)
end

#poolObject


116
117
118
# File 'lib/tribe/actable.rb', line 116

def pool
  @_actable.pool
end

#registryObject


112
113
114
# File 'lib/tribe/actable.rb', line 112

def registry
  @_actable.registry
end

#shutdown!Object


60
61
62
# File 'lib/tribe/actable.rb', line 60

def shutdown!
  direct_message!(:__shutdown__)
end

#spawn!(klass, actor_options = {}, spawn_options = {}) ⇒ Object


68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/tribe/actable.rb', line 68

def spawn!(klass, actor_options = {}, spawn_options = {})
  actor_options[:parent] = self

  child = nil

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

  @_actable.children.add(child)

  if spawn_options[:supervise]
    @_actable.supervisees.add(child)
  end

  child
end