Class: OFlow::Actor

Inherits:
Object
  • Object
show all
Defined in:
lib/oflow/actor.rb

Overview

Actors provide the custom functionality for Tasks. Each Task creates an instance of some Actor. Actors are not shared between Tasks and each can be assure that the data they operate on is their own.

Defined Under Namespace

Classes: Spec

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(task, options) ⇒ Actor

Creates a new instance.

Parameters:

  • task (Task)

    enclosing Task

  • options (Hash)

    additional options



15
16
17
# File 'lib/oflow/actor.rb', line 15

def initialize(task, options)
  @task = task
end

Instance Attribute Details

#taskObject (readonly)

The enclosing task.



10
11
12
# File 'lib/oflow/actor.rb', line 10

def task
  @task
end

Instance Method Details

#busy?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/oflow/actor.rb', line 55

def busy?()
  false
end

#inputsArray

Return array of Specs.

Returns:

  • (Array)

    Array of Specs.



35
36
37
# File 'lib/oflow/actor.rb', line 35

def inputs()
  nil
end

#optionsHash

Return any options that should be displayed as part of a Task.describe().

Returns:

  • (Hash)

    Hash of options with String keys.



51
52
53
# File 'lib/oflow/actor.rb', line 51

def options()
  {}
end

#outputsArray

Return array of Specs.

Returns:

  • (Array)

    Array of Specs.



41
42
43
# File 'lib/oflow/actor.rb', line 41

def outputs()
  nil
end

#perform(op, box) ⇒ Object

Perform the primary functions for the Actor.

Parameters:

  • op (Symbol)

    operation to perform

  • box (Box)

    contents or data for the operation



22
23
# File 'lib/oflow/actor.rb', line 22

def perform(op, box)
end

#set_option(key, value) ⇒ Object



45
46
47
# File 'lib/oflow/actor.rb', line 45

def set_option(key, value)
  set_options({ key.to_sym => value })
end

#with_own_threadtrue|false

Returns whether the Actor should have it’s own thread or not. In almost all cases the Actor should have it’s own thread. The exception is when the action is trivial such as a relay.

Returns:

  • (true|false)

    indicator of whether a new thread should be created.



29
30
31
# File 'lib/oflow/actor.rb', line 29

def with_own_thread()
  true
end