amqp 1.0.0.pre1 → 1.0.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/amqp.gemspec +2 -2
- data/lib/amqp/bit_set.rb +5 -76
- data/lib/amqp/int_allocator.rb +4 -91
- data/lib/amqp/version.rb +1 -1
- metadata +11 -11
data/amqp.gemspec
CHANGED
@@ -24,8 +24,8 @@ Gem::Specification.new do |s|
|
|
24
24
|
|
25
25
|
# Dependencies
|
26
26
|
s.add_dependency "eventmachine"
|
27
|
-
s.add_dependency "amq-client", "~> 1.0.0.
|
28
|
-
s.add_dependency "amq-protocol", "~> 1.0.0.
|
27
|
+
s.add_dependency "amq-client", "~> 1.0.0.pre2"
|
28
|
+
s.add_dependency "amq-protocol", "~> 1.0.0.pre6"
|
29
29
|
|
30
30
|
begin
|
31
31
|
require "changelog"
|
data/lib/amqp/bit_set.rb
CHANGED
@@ -1,80 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
|
4
|
-
# Very minimalistic, pure Ruby implementation of bit set. Inspired by java.util.BitSet,
|
5
|
-
# although significantly smaller in scope.
|
6
|
-
class BitSet
|
7
|
-
|
8
|
-
#
|
9
|
-
# API
|
10
|
-
#
|
11
|
-
|
12
|
-
ADDRESS_BITS_PER_WORD = 6
|
13
|
-
BITS_PER_WORD = (1 << ADDRESS_BITS_PER_WORD)
|
14
|
-
WORD_MASK = 0xffffffffffffffff
|
15
|
-
|
16
|
-
# @param [Integer] Number of bits in the set
|
17
|
-
# @api public
|
18
|
-
def initialize(nbits)
|
19
|
-
@nbits = nbits
|
20
|
-
|
21
|
-
self.init_words(nbits)
|
22
|
-
end # initialize(nbits)
|
23
|
-
|
24
|
-
# Sets (flags) given bit. This method allows bits to be set more than once in a row, no exception will be raised.
|
25
|
-
#
|
26
|
-
# @param [Integer] A bit to set
|
27
|
-
# @api public
|
28
|
-
def set(i)
|
29
|
-
w = self.word_index(i)
|
30
|
-
@words[w] |= (1 << i)
|
31
|
-
end # set(i)
|
32
|
-
|
33
|
-
# Fetches flag value for given bit.
|
34
|
-
#
|
35
|
-
# @param [Integer] A bit to fetch
|
36
|
-
# @return [Boolean] true if given bit is set, false otherwise
|
37
|
-
# @api public
|
38
|
-
def get(i)
|
39
|
-
w = self.word_index(i)
|
40
|
-
|
41
|
-
(@words[w] & (1 << i)) != 0
|
42
|
-
end # get(i)
|
43
|
-
alias [] get
|
3
|
+
require "amq/bit_set"
|
44
4
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
def unset(i)
|
50
|
-
w = self.word_index(i)
|
51
|
-
return if w.nil?
|
52
|
-
|
53
|
-
@words[w] &= ~(1 << i)
|
54
|
-
end # unset(i)
|
55
|
-
|
56
|
-
# Clears all bits in the set
|
57
|
-
# @api public
|
58
|
-
def clear
|
59
|
-
self.init_words(@nbits)
|
60
|
-
end # clear
|
61
|
-
|
62
|
-
|
63
|
-
#
|
64
|
-
# Implementation
|
65
|
-
#
|
66
|
-
|
67
|
-
protected
|
68
|
-
|
69
|
-
# @private
|
70
|
-
def init_words(nbits)
|
71
|
-
n = word_index(nbits-1) + 1
|
72
|
-
@words = Array.new(n) { 1 }
|
73
|
-
end # init_words
|
74
|
-
|
75
|
-
# @private
|
76
|
-
def word_index(i)
|
77
|
-
i >> ADDRESS_BITS_PER_WORD
|
78
|
-
end # word_index(i)
|
79
|
-
end # BitSet
|
5
|
+
module AMQP
|
6
|
+
# A forward reference for AMQP::BitSet that was extracted to amq-protocol
|
7
|
+
# to make it possible to reuse it in Bunny.
|
8
|
+
BitSet = AMQ::BitSet
|
80
9
|
end # AMQP
|
data/lib/amqp/int_allocator.rb
CHANGED
@@ -1,96 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "amq/int_allocator"
|
4
4
|
|
5
5
|
module AMQP
|
6
|
-
#
|
7
|
-
#
|
8
|
-
|
9
|
-
# Unlike monotonically incrementing identifier, this allocator is suitable for very long running programs
|
10
|
-
# that aggressively allocate and release channels.
|
11
|
-
class IntAllocator
|
12
|
-
|
13
|
-
#
|
14
|
-
# API
|
15
|
-
#
|
16
|
-
|
17
|
-
# @return [Integer] Number of integers in the allocation range
|
18
|
-
attr_reader :number_of_bits
|
19
|
-
# @return [Integer] Upper boundary of the integer range available for allocation
|
20
|
-
attr_reader :hi
|
21
|
-
# @return [Integer] Lower boundary of the integer range available for allocation
|
22
|
-
attr_reader :lo
|
23
|
-
|
24
|
-
# @param [Integer] lo Lower boundary of the integer range available for allocation
|
25
|
-
# @param [Integer] hi Upper boundary of the integer range available for allocation
|
26
|
-
# @raise [ArgumentError] if upper boundary is not greater than the lower one
|
27
|
-
def initialize(lo, hi)
|
28
|
-
raise ArgumentError.new "upper boundary must be greater than the lower one (given: hi = #{hi}, lo = #{lo})" unless hi > lo
|
29
|
-
|
30
|
-
@hi = hi
|
31
|
-
@lo = lo
|
32
|
-
|
33
|
-
@number_of_bits = hi - lo
|
34
|
-
@range = Range.new(1, @number_of_bits)
|
35
|
-
@free_set = BitSet.new(@number_of_bits)
|
36
|
-
end # initialize(hi, lo)
|
37
|
-
|
38
|
-
# Attempts to allocate next available integer. If allocation succeeds, allocated value is returned.
|
39
|
-
# Otherwise, nil is returned.
|
40
|
-
#
|
41
|
-
# Current implementation of this method is O(n), where n is number of bits in the range available for
|
42
|
-
# allocation.
|
43
|
-
#
|
44
|
-
# @return [Integer] Allocated integer if allocation succeeded. nil otherwise.
|
45
|
-
def allocate
|
46
|
-
if n = find_unallocated_position
|
47
|
-
@free_set.set(n)
|
48
|
-
|
49
|
-
n
|
50
|
-
else
|
51
|
-
-1
|
52
|
-
end
|
53
|
-
end # allocate
|
54
|
-
|
55
|
-
# Releases previously allocated integer. If integer provided as argument was not previously allocated,
|
56
|
-
# this method has no effect.
|
57
|
-
#
|
58
|
-
# @return [NilClass] nil
|
59
|
-
def free(reservation)
|
60
|
-
@free_set.unset(reservation)
|
61
|
-
end # free(reservation)
|
62
|
-
alias release free
|
63
|
-
|
64
|
-
# @return [Boolean] true if provided argument was previously allocated, false otherwise
|
65
|
-
def allocated?(reservation)
|
66
|
-
@free_set.get(reservation)
|
67
|
-
end # allocated?(reservation)
|
68
|
-
|
69
|
-
# Releases the whole allocation range
|
70
|
-
def reset
|
71
|
-
@free_set.clear
|
72
|
-
end # reset
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
protected
|
77
|
-
|
78
|
-
# This implementation is significantly less efficient
|
79
|
-
# that what the RabbitMQ Java client has (based on java.lang.Long#nextSetBit and
|
80
|
-
# java.lang.Long.numberOfTrailingZeros, and thus binary search over bits).
|
81
|
-
# But for channel id generation, this is a good enough implementation.
|
82
|
-
#
|
83
|
-
# @private
|
84
|
-
def find_unallocated_position
|
85
|
-
r = nil
|
86
|
-
@range.each do |i|
|
87
|
-
if !@free_set.get(i)
|
88
|
-
r = i
|
89
|
-
break;
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
r
|
94
|
-
end # find_unallocated_position
|
95
|
-
end # IntAllocator
|
6
|
+
# A forward reference for AMQP::IntAllocator that was extracted to amq-protocol
|
7
|
+
# to make it possible to reuse it in Bunny.
|
8
|
+
IntAllocator = AMQ::IntAllocator
|
96
9
|
end # AMQP
|
data/lib/amqp/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amqp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: -1633158744
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
9
|
- 0
|
10
10
|
- pre
|
11
|
-
-
|
12
|
-
version: 1.0.0.
|
11
|
+
- 2
|
12
|
+
version: 1.0.0.pre2
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Aman Gupta
|
@@ -19,7 +19,7 @@ autorequire:
|
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
21
|
|
22
|
-
date: 2012-
|
22
|
+
date: 2012-07-03 00:00:00 Z
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|
25
25
|
name: eventmachine
|
@@ -43,14 +43,14 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - ~>
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
hash:
|
46
|
+
hash: -1633158744
|
47
47
|
segments:
|
48
48
|
- 1
|
49
49
|
- 0
|
50
50
|
- 0
|
51
51
|
- pre
|
52
|
-
-
|
53
|
-
version: 1.0.0.
|
52
|
+
- 2
|
53
|
+
version: 1.0.0.pre2
|
54
54
|
type: :runtime
|
55
55
|
version_requirements: *id002
|
56
56
|
- !ruby/object:Gem::Dependency
|
@@ -61,14 +61,14 @@ dependencies:
|
|
61
61
|
requirements:
|
62
62
|
- - ~>
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
hash:
|
64
|
+
hash: -1633158752
|
65
65
|
segments:
|
66
66
|
- 1
|
67
67
|
- 0
|
68
68
|
- 0
|
69
69
|
- pre
|
70
|
-
-
|
71
|
-
version: 1.0.0.
|
70
|
+
- 6
|
71
|
+
version: 1.0.0.pre6
|
72
72
|
type: :runtime
|
73
73
|
version_requirements: *id003
|
74
74
|
description: Widely used, feature-rich asynchronous AMQP 0.9.1 client with batteries included.
|
@@ -350,7 +350,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
350
350
|
requirements: []
|
351
351
|
|
352
352
|
rubyforge_project: amqp
|
353
|
-
rubygems_version: 1.8.
|
353
|
+
rubygems_version: 1.8.24
|
354
354
|
signing_key:
|
355
355
|
specification_version: 3
|
356
356
|
summary: Widely used, feature-rich asynchronous AMQP 0.9.1 client with batteries included
|