Class: ModSpox::Pool

Inherits:
Object
  • Object
show all
Defined in:
lib/mod_spox/Pool.rb

Overview

The Pool class is used to reduce thread creation. It provides an easy way to process many actions in an asynchronous manner.

Direct Known Subclasses

MessageFactory, Pipeline, Socket, Timer

Defined Under Namespace

Classes: PoolQueue

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePool

Create a new pool



18
19
20
21
# File 'lib/mod_spox/Pool.rb', line 18

def initialize
    @proc = Proc.new{ run_processor }
    @queue = PoolQueue.new
end

Instance Attribute Details

#procObject (readonly)

Action thread is to perform



13
14
15
# File 'lib/mod_spox/Pool.rb', line 13

def proc
  @proc
end

#queueObject (readonly)

Storage space that the pool will be processing



15
16
17
# File 'lib/mod_spox/Pool.rb', line 15

def queue
  @queue
end

Instance Method Details

#destroyObject

Destroys this pool



24
25
26
# File 'lib/mod_spox/Pool.rb', line 24

def destroy
    Pool.remove_pool(self)
end

#start_poolObject

Starts the pool



29
30
31
# File 'lib/mod_spox/Pool.rb', line 29

def start_pool
    Pool.add_pool(self)
end