Class: Dramatis::Runtime::ThreadPool

Inherits:
Object
  • Object
show all
Defined in:
lib/dramatis/runtime/thread_pool.rb,
lib/dramatis/runtime/thread_pool.rb

Overview

:nodoc: all

Defined Under Namespace

Classes: PoolThread

Instance Method Summary collapse

Constructor Details

#initializeThreadPool

Returns a new instance of ThreadPool.



14
15
16
17
18
19
# File 'lib/dramatis/runtime/thread_pool.rb', line 14

def initialize
  super
  @mutex = Mutex.new
  @threads = []
  @state = :running
end

Instance Method Details

#lengthObject



25
26
27
28
29
# File 'lib/dramatis/runtime/thread_pool.rb', line 25

def length
  @mutex.synchronize do
    @threads.length
  end
end

#new(&block) ⇒ Object



21
22
23
# File 'lib/dramatis/runtime/thread_pool.rb', line 21

def new &block
  checkout( &block )
end

#resetObject



9
10
11
12
# File 'lib/dramatis/runtime/thread_pool.rb', line 9

def reset
  shutdown
  @state = :running
end