Class: Pushlet::GatewayPool
- Inherits:
-
Object
- Object
- Pushlet::GatewayPool
- Defined in:
- lib/pushlet/gateway_pool.rb
Instance Method Summary collapse
- #add(id, gateway) ⇒ Object
- #get(id) ⇒ Object
-
#initialize ⇒ GatewayPool
constructor
A new instance of GatewayPool.
- #remove(id) ⇒ Object
Constructor Details
#initialize ⇒ GatewayPool
Returns a new instance of GatewayPool.
3 4 5 6 |
# File 'lib/pushlet/gateway_pool.rb', line 3 def initialize @mutex = Mutex.new @pool = {} end |
Instance Method Details
#add(id, gateway) ⇒ Object
12 13 14 15 16 |
# File 'lib/pushlet/gateway_pool.rb', line 12 def add(id, gateway) lock { @pool[id.to_sym] = gateway } end |
#get(id) ⇒ Object
8 9 10 |
# File 'lib/pushlet/gateway_pool.rb', line 8 def get(id) @pool[id.to_sym] end |
#remove(id) ⇒ Object
18 19 20 21 22 |
# File 'lib/pushlet/gateway_pool.rb', line 18 def remove(id) lock { @pool.delete id.to_sym } end |