multi_op_queue 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -3
- data/lib/multi_op_queue/version.rb +1 -1
- data/lib/multi_op_queue.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e7e8948258b342529f1d42f0cac55b83f5a2d62
|
4
|
+
data.tar.gz: 70af985eebf916e51ab87b06dddd240c1e74bae6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30324cb47f48fafc2d04956a24f06c1cc11d9a701a2697cd3f612c76bcdf267c094bbef0287d0750061a9fd99d597fb6335ee1878ea3343a16d62fb79d84edf0
|
7
|
+
data.tar.gz: 7add1f7a89ffec976363278700f8be9333803cbca7b2a619b9c466898b9de895a0b7692cf04d0490b042fec386561a13a0e7c1a355c2f16199aa1d92d7342bc1
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# MultiOpQueue
|
2
2
|
|
3
|
-
|
3
|
+
Pure Ruby implementation of a Queue (from ruby-2.0.0) which also support multi-value operations while retaining the lock that protects the queue
|
4
4
|
|
5
|
-
|
5
|
+
### Example
|
6
|
+
`pop_up_to` will return an array of values from the queue (up to the number specified) with only a single acquisition of the lock
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
@@ -22,7 +23,16 @@ Or install it yourself as:
|
|
22
23
|
|
23
24
|
## Usage
|
24
25
|
|
25
|
-
|
26
|
+
```ruby
|
27
|
+
require 'multi_op_queue'
|
28
|
+
|
29
|
+
queue = ::MutiOpQueue::Queue.new
|
30
|
+
queue.push(1)
|
31
|
+
queue.push(2)
|
32
|
+
|
33
|
+
items = queue.pop_up_to(2)
|
34
|
+
# [ 1, 2 ]
|
35
|
+
```
|
26
36
|
|
27
37
|
## Development
|
28
38
|
|
data/lib/multi_op_queue.rb
CHANGED
@@ -43,6 +43,18 @@ module MultiOpQueue
|
|
43
43
|
@cond = ConditionVariable.new
|
44
44
|
end
|
45
45
|
|
46
|
+
#
|
47
|
+
# Concatenates +ary+ onto the queue.
|
48
|
+
#
|
49
|
+
def concat(ary)
|
50
|
+
Thread.handle_interrupt(StandardError => :on_blocking) do
|
51
|
+
@mutex.synchronize do
|
52
|
+
@que.concat ary
|
53
|
+
@cond.signal
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
46
58
|
#
|
47
59
|
# Pushes +obj+ to the queue.
|
48
60
|
#
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multi_op_queue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Dewitt
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|