Class: Amazon::Util::ThreadPool::WorkItem
- Inherits:
-
Object
- Object
- Amazon::Util::ThreadPool::WorkItem
- Defined in:
- lib/amazon/util/threadpool.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
Instance Method Summary collapse
- #getResult ⇒ Object
-
#initialize(args, &block) ⇒ WorkItem
constructor
A new instance of WorkItem.
- #run ⇒ Object
Constructor Details
#initialize(args, &block) ⇒ WorkItem
Returns a new instance of WorkItem.
107 108 109 110 111 |
# File 'lib/amazon/util/threadpool.rb', line 107 def initialize( args, &block ) @args = args @block = block @result = Queue.new end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
106 107 108 |
# File 'lib/amazon/util/threadpool.rb', line 106 def args @args end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
106 107 108 |
# File 'lib/amazon/util/threadpool.rb', line 106 def block @block end |
Instance Method Details
#getResult ⇒ Object
119 120 121 122 123 |
# File 'lib/amazon/util/threadpool.rb', line 119 def getResult value = @result.pop @result = [value] value end |
#run ⇒ Object
112 113 114 115 116 117 118 |
# File 'lib/amazon/util/threadpool.rb', line 112 def run res = @block.call( *@args) @result.push res rescue Exception => e @result.push e raise e end |