Class: Fasten::Task
- Inherits:
-
Object
- Object
- Fasten::Task
- Includes:
- Support::State
- Defined in:
- lib/fasten/task.rb
Instance Attribute Summary collapse
-
#after ⇒ Object
Returns the value of attribute after.
-
#block ⇒ Object
Returns the value of attribute block.
-
#dependants ⇒ Object
Returns the value of attribute dependants.
-
#depends ⇒ Object
Returns the value of attribute depends.
-
#name ⇒ Object
Returns the value of attribute name.
-
#request ⇒ Object
Returns the value of attribute request.
-
#response ⇒ Object
Returns the value of attribute response.
-
#ruby ⇒ Object
Returns the value of attribute ruby.
-
#run_score ⇒ Object
Returns the value of attribute run_score.
-
#shell ⇒ Object
Returns the value of attribute shell.
-
#weight ⇒ Object
Returns the value of attribute weight.
-
#worker ⇒ Object
Returns the value of attribute worker.
-
#worker_class ⇒ Object
Returns the value of attribute worker_class.
Attributes included from Support::State
#dif, #error, #fin, #ini, #runner, #state
Instance Method Summary collapse
-
#initialize(name:, shell: nil, ruby: nil, block: nil, request: nil, after: nil, weight: 1, worker_class: nil) ⇒ Task
constructor
A new instance of Task.
- #kind ⇒ Object
- #marshal_dump ⇒ Object
- #marshal_load(data) ⇒ Object
- #to_s ⇒ Object
Methods included from Support::State
#deps, #deps_str, #deps_str_runner, #deps_str_task, #idle?, #last_avg, #last_err, #last_stat, #paused?, #pausing?, #quitting?, #running?
Constructor Details
#initialize(name:, shell: nil, ruby: nil, block: nil, request: nil, after: nil, weight: 1, worker_class: nil) ⇒ Task
Returns a new instance of Task.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fasten/task.rb', line 9 def initialize(name:, shell: nil, ruby: nil, block: nil, request: nil, after: nil, weight: 1, worker_class: nil) self.name = name self.shell = shell self.ruby = ruby self.block = block self.request = request self.after = after self.weight = weight self.worker_class = worker_class # ObjectSpace.define_finalizer(self) do # puts "I am dying! pid: #{Process.pid} thread: #{Thread.current} TASK #{@name}" # end block&.object_id # block && begin # # puts "block_id: #{block.object_id} for task #{@name}" # end # block && ObjectSpace.define_finalizer(block) do # puts "I am dying! pid: #{Process.pid} thread: #{Thread.current} TASK #{@name} BLOCK" # end end |
Instance Attribute Details
#after ⇒ Object
Returns the value of attribute after.
7 8 9 |
# File 'lib/fasten/task.rb', line 7 def after @after end |
#block ⇒ Object
Returns the value of attribute block.
7 8 9 |
# File 'lib/fasten/task.rb', line 7 def block @block end |
#dependants ⇒ Object
Returns the value of attribute dependants.
7 8 9 |
# File 'lib/fasten/task.rb', line 7 def dependants @dependants end |
#depends ⇒ Object
Returns the value of attribute depends.
7 8 9 |
# File 'lib/fasten/task.rb', line 7 def depends @depends end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/fasten/task.rb', line 7 def name @name end |
#request ⇒ Object
Returns the value of attribute request.
7 8 9 |
# File 'lib/fasten/task.rb', line 7 def request @request end |
#response ⇒ Object
Returns the value of attribute response.
7 8 9 |
# File 'lib/fasten/task.rb', line 7 def response @response end |
#ruby ⇒ Object
Returns the value of attribute ruby.
7 8 9 |
# File 'lib/fasten/task.rb', line 7 def ruby @ruby end |
#run_score ⇒ Object
Returns the value of attribute run_score.
7 8 9 |
# File 'lib/fasten/task.rb', line 7 def run_score @run_score end |
#shell ⇒ Object
Returns the value of attribute shell.
7 8 9 |
# File 'lib/fasten/task.rb', line 7 def shell @shell end |
#weight ⇒ Object
Returns the value of attribute weight.
7 8 9 |
# File 'lib/fasten/task.rb', line 7 def weight @weight end |
#worker ⇒ Object
Returns the value of attribute worker.
7 8 9 |
# File 'lib/fasten/task.rb', line 7 def worker @worker end |
#worker_class ⇒ Object
Returns the value of attribute worker_class.
7 8 9 |
# File 'lib/fasten/task.rb', line 7 def worker_class @worker_class end |
Instance Method Details
#kind ⇒ Object
49 50 51 |
# File 'lib/fasten/task.rb', line 49 def kind 'task' end |
#marshal_dump ⇒ Object
34 35 36 |
# File 'lib/fasten/task.rb', line 34 def marshal_dump [@name, @state, @ini, @fin, @dif, @request, @response, @shell, @ruby, @block&.object_id, @error] end |
#marshal_load(data) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fasten/task.rb', line 38 def marshal_load(data) @name, @state, @ini, @fin, @dif, @request, @response, @shell, @ruby, block_id, @error = data @block = begin ObjectSpace._id2ref block_id.to_i if block_id rescue StandardError # pass end raise "Sorry, unable to get block for task #{self}, please try using threads" if block_id && !@block.is_a?(Proc) end |
#to_s ⇒ Object
53 54 55 |
# File 'lib/fasten/task.rb', line 53 def to_s name end |