Class: WorkerThreadSet

Inherits:
Set
  • Object
show all
Defined in:
lib/codegrinder/worker_thread_set.rb

Overview

A set of worker threads, whose behavior is the very same

Defined Under Namespace

Classes: NullWorkerThreadSet

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(count, &block) ⇒ WorkerThreadSet

Returns a new instance of WorkerThreadSet.



9
10
11
12
13
# File 'lib/codegrinder/worker_thread_set.rb', line 9

def initialize(count, &block)
  fail(RuntimError, 'Missing block') if block.nil?
  super()
  count.times { self << Thread.new(&block) }
end

Class Method Details

.null_objectObject



19
20
21
# File 'lib/codegrinder/worker_thread_set.rb', line 19

def self.null_object
  NullWorkerThreadSet.instance
end

Instance Method Details

#joinObject



15
16
17
# File 'lib/codegrinder/worker_thread_set.rb', line 15

def join
  each(&:join)
end