Sha256: 3efc7348ec0fedeaf9fc77ac9f1752cd3f92370b8ee8504d77371684a7e57931
Contents?: true
Size: 519 Bytes
Versions: 6
Compression:
Stored size: 519 Bytes
Contents
class ThreadWorker attr_reader :work_done def initialize(blackboard, expected_work) @blackboard, @expected_work = blackboard, expected_work @thread = Thread.new {run} end def wait_until_done Timeout.timeout(5) {@thread.join} @thread.kill if @thread.alive? end def run @work_done = 0 until @work_done >= @expected_work Thread.pass work = @blackboard.take_work if work @blackboard.write_result work.run @work_done += 1 end end end end
Version data entries
6 entries across 6 versions & 2 rubygems