Module: AMQP::ChannelIdAllocator
- Included in:
- Session
- Defined in:
- lib/amqp/channel_id_allocator.rb
Constant Summary collapse
- MAX_CHANNELS_PER_CONNECTION =
(2**16) - 1
Instance Method Summary collapse
-
#next_channel_id ⇒ Fixnum
Returns next available channel id.
-
#release_channel_id(i) ⇒ Object
Releases previously allocated channel id.
-
#reset_channel_id_allocator ⇒ Object
Resets channel allocator.
Instance Method Details
#next_channel_id ⇒ Fixnum
Returns next available channel id. This method is thread safe.
34 35 36 37 38 39 40 |
# File 'lib/amqp/channel_id_allocator.rb', line 34 def next_channel_id channel_id_mutex.synchronize do result = int_allocator.allocate raise "No further channels available. Please open a new connection." if result < 0 result end end |
#release_channel_id(i) ⇒ Object
Releases previously allocated channel id. This method is thread safe.
22 23 24 25 26 |
# File 'lib/amqp/channel_id_allocator.rb', line 22 def release_channel_id(i) channel_id_mutex.synchronize do int_allocator.release(i) end end |
#reset_channel_id_allocator ⇒ Object
Resets channel allocator. This method is thread safe.
10 11 12 13 14 |
# File 'lib/amqp/channel_id_allocator.rb', line 10 def reset_channel_id_allocator channel_id_mutex.synchronize do int_allocator.reset end end |