Class: ModSpox::Pool::PoolQueue
- Inherits:
-
Queue
- Object
- Queue
- ModSpox::Pool::PoolQueue
- Defined in:
- lib/mod_spox/Pool.rb
Overview
Modified Queue to properly interact with Pool
Instance Method Summary collapse
- #<<(val) ⇒ Object
-
#initialize ⇒ PoolQueue
constructor
A new instance of PoolQueue.
- #pop ⇒ Object
- #push(val) ⇒ Object
Constructor Details
#initialize ⇒ PoolQueue
Returns a new instance of PoolQueue.
116 117 118 119 |
# File 'lib/mod_spox/Pool.rb', line 116 def initialize super @lock = Mutex.new end |
Instance Method Details
#<<(val) ⇒ Object
121 122 123 124 125 126 |
# File 'lib/mod_spox/Pool.rb', line 121 def <<(val) @lock.synchronize do super Pool.process end end |
#pop ⇒ Object
135 136 137 138 139 140 141 142 143 |
# File 'lib/mod_spox/Pool.rb', line 135 def pop @lock.synchronize do if(size > 0) super else raise Exceptions::BotException.new("Queue is currently empty") end end end |
#push(val) ⇒ Object
128 129 130 131 132 133 |
# File 'lib/mod_spox/Pool.rb', line 128 def push(val) @lock.synchronize do super Pool.process end end |