Class: ModSpox::Pool::PoolQueue

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

Overview

Modified Queue to properly interact with Pool

Instance Method Summary collapse

Constructor Details

#initializePoolQueue

Returns a new instance of PoolQueue.



148
149
150
151
# File 'lib/mod_spox/Pool.rb', line 148

def initialize
    super
    @lock = Mutex.new
end

Instance Method Details

#<<(val) ⇒ Object



153
154
155
# File 'lib/mod_spox/Pool.rb', line 153

def <<(val)
    push(val)
end

#popObject



164
165
166
167
168
169
170
171
172
# File 'lib/mod_spox/Pool.rb', line 164

def pop
    @lock.synchronize do
        if(size > 0)
            super
        else
            raise Exceptions::BotException.new("Queue is currently empty")
        end
    end
end

#push(val) ⇒ Object



157
158
159
160
161
162
# File 'lib/mod_spox/Pool.rb', line 157

def push(val)
    @lock.synchronize do
        super
    end
    Pool.process
end