Class: Fasten::Worker
- Inherits:
-
Object
- Object
- Fasten::Worker
- Includes:
- Support::Logger, Support::State
- Defined in:
- lib/fasten/worker.rb
Instance Attribute Summary collapse
-
#child_read ⇒ Object
Returns the value of attribute child_read.
-
#child_write ⇒ Object
Returns the value of attribute child_write.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent_read ⇒ Object
Returns the value of attribute parent_read.
-
#parent_write ⇒ Object
Returns the value of attribute parent_write.
-
#runner ⇒ Object
Returns the value of attribute runner.
-
#running_task ⇒ Object
Returns the value of attribute running_task.
-
#spinner ⇒ Object
Returns the value of attribute spinner.
Attributes included from Support::State
#dif, #error, #fin, #ini, #state
Attributes included from Support::Logger
Instance Method Summary collapse
-
#initialize(runner:, name: nil, use_threads: nil) ⇒ Worker
constructor
A new instance of Worker.
- #kind ⇒ Object
- #perform(task) ⇒ 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?
Methods included from Support::Logger
#close_logger, #initialize_logger, #log_fin, #log_ini
Constructor Details
#initialize(runner:, name: nil, use_threads: nil) ⇒ Worker
Returns a new instance of Worker.
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fasten/worker.rb', line 23 def initialize(runner:, name: nil, use_threads: nil) if use_threads extend Fasten::Support::ThreadWorker else extend Fasten::Support::ForkWorker end self.runner = runner self.name = name self.spinner = 0 initialize_logger(log_file: runner.log_file) if runner end |
Instance Attribute Details
#child_read ⇒ Object
Returns the value of attribute child_read.
21 22 23 |
# File 'lib/fasten/worker.rb', line 21 def child_read @child_read end |
#child_write ⇒ Object
Returns the value of attribute child_write.
21 22 23 |
# File 'lib/fasten/worker.rb', line 21 def child_write @child_write end |
#name ⇒ Object
Returns the value of attribute name.
21 22 23 |
# File 'lib/fasten/worker.rb', line 21 def name @name end |
#parent_read ⇒ Object
Returns the value of attribute parent_read.
21 22 23 |
# File 'lib/fasten/worker.rb', line 21 def parent_read @parent_read end |
#parent_write ⇒ Object
Returns the value of attribute parent_write.
21 22 23 |
# File 'lib/fasten/worker.rb', line 21 def parent_write @parent_write end |
#runner ⇒ Object
Returns the value of attribute runner.
21 22 23 |
# File 'lib/fasten/worker.rb', line 21 def runner @runner end |
#running_task ⇒ Object
Returns the value of attribute running_task.
21 22 23 |
# File 'lib/fasten/worker.rb', line 21 def running_task @running_task end |
#spinner ⇒ Object
Returns the value of attribute spinner.
21 22 23 |
# File 'lib/fasten/worker.rb', line 21 def spinner @spinner end |
Instance Method Details
#kind ⇒ Object
47 48 49 |
# File 'lib/fasten/worker.rb', line 47 def kind 'worker' end |
#perform(task) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/fasten/worker.rb', line 37 def perform(task) if task.ruby perform_ruby(task) elsif task.shell perform_shell(task) elsif task.block perform_block(task, task.block) end end |
#to_s ⇒ Object
51 52 53 |
# File 'lib/fasten/worker.rb', line 51 def to_s name end |