Class: Boogaloo::ThreadPool

Inherits:
Queue
  • Object
show all
Defined in:
lib/boogaloo/thread_pool.rb

Instance Method Summary collapse

Constructor Details

#initialize(threads) ⇒ ThreadPool

Initailize a new thread pool.

Parameters:

threads

The number of threads to populate the pool with.



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/boogaloo/thread_pool.rb', line 10

def initialize(threads)

    super()

    @threads = threads

    for i in 1..@threads

        push(Boogaloo::WorkerThread.new)
    
    end

end

Instance Method Details

#shutdown ⇒ Object

Shutdown the pool.



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/boogaloo/thread_pool.rb', line 25

def shutdown
       
    for i in 1..@threads
    
        worker = pop
        worker.exit
        
    end
    
    size == 0 ? true : false

end