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

Instance Method Details

#next_channel_idFixnum

Returns next available channel id. This method is thread safe.

Returns:

  • (Fixnum)

See Also:

  • Channel.release_channel_id
  • Channel.reset_channel_id_allocator


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.

Parameters:

  • Channel (Fixnum)

    id to release

See Also:

  • Channel.next_channel_id
  • Channel.reset_channel_id_allocator


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_allocatorObject

Resets channel allocator. This method is thread safe.

See Also:

  • Channel.next_channel_id
  • Channel.release_channel_id


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