Class: Amazon::Util::ThreadPool::WorkItem

Inherits:
Object
  • Object
show all
Defined in:
lib/amazon/util/threadpool.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#argsObject (readonly)

Returns the value of attribute args.



106
107
108
# File 'lib/amazon/util/threadpool.rb', line 106

def args
  @args
end

#blockObject (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

#getResultObject



119
120
121
122
123
# File 'lib/amazon/util/threadpool.rb', line 119

def getResult
  value = @result.pop
  @result = [value]
  value
end

#runObject



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