Class: Contender::SimpleThreadFactory

Inherits:
ThreadFactory show all
Defined in:
lib/contender/thread_factory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeundefined



20
21
22
23
# File 'lib/contender/thread_factory.rb', line 20

def initialize
  @group = ThreadGroup.new
  @priority = 0
end

Instance Attribute Details

#groupThreadGroup (readonly)

Returns:

  • (ThreadGroup)


14
15
16
# File 'lib/contender/thread_factory.rb', line 14

def group
  @group
end

#priorityInteger

Returns:

  • (Integer)


17
18
19
# File 'lib/contender/thread_factory.rb', line 17

def priority
  @priority
end

Instance Method Details

#create { ... } ⇒ Thread

Yields:

Returns:

  • (Thread)


28
29
30
31
32
33
34
35
# File 'lib/contender/thread_factory.rb', line 28

def create(&block)
  thread = Thread.new &block
  thread.priority = @priority

  @group.add thread

  thread
end