Class: Pushlet::GatewayPool

Inherits:
Object
  • Object
show all
Defined in:
lib/pushlet/gateway_pool.rb

Instance Method Summary collapse

Constructor Details

#initializeGatewayPool

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