Class: Actor::Substitutes::Thread
- Inherits:
-
Object
- Object
- Actor::Substitutes::Thread
- Defined in:
- lib/actor/substitutes/thread.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#name ⇒ Object
Returns the value of attribute name.
-
#priority ⇒ Object
Returns the value of attribute priority.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #alive? ⇒ Boolean
-
#initialize(&block) ⇒ Thread
constructor
A new instance of Thread.
- #join(limit = nil) ⇒ Object
- #stop? ⇒ Boolean
Constructor Details
#initialize(&block) ⇒ Thread
Returns a new instance of Thread.
9 10 11 12 13 14 |
# File 'lib/actor/substitutes/thread.rb', line 9 def initialize &block @status = 'run' @priority = 0 @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
4 5 6 |
# File 'lib/actor/substitutes/thread.rb', line 4 def block @block end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/actor/substitutes/thread.rb', line 5 def name @name end |
#priority ⇒ Object
Returns the value of attribute priority.
6 7 8 |
# File 'lib/actor/substitutes/thread.rb', line 6 def priority @priority end |
#status ⇒ Object
Returns the value of attribute status.
7 8 9 |
# File 'lib/actor/substitutes/thread.rb', line 7 def status @status end |
Instance Method Details
#alive? ⇒ Boolean
30 31 32 |
# File 'lib/actor/substitutes/thread.rb', line 30 def alive? %w(sleep run).include? status end |
#join(limit = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/actor/substitutes/thread.rb', line 16 def join limit=nil if limit begin Timeout.timeout limit, &block rescue Timeout::Error return nil end else block.() end self end |
#stop? ⇒ Boolean
34 35 36 |
# File 'lib/actor/substitutes/thread.rb', line 34 def stop? status != 'run' end |