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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 495fd7b92b83ff144c091ac3e9f9124a6830714e
4
- data.tar.gz: 307b88bd5f82abbfdaf30345db0310704bf55595
3
+ metadata.gz: 6e7e8948258b342529f1d42f0cac55b83f5a2d62
4
+ data.tar.gz: 70af985eebf916e51ab87b06dddd240c1e74bae6
5
5
  SHA512:
6
- metadata.gz: 867d4a9e939310882713f7ad0d1dff2750513e177a484fd096c4f8beccaa7a9f1f5edfc736a052e480031c56e7d3711c6c669a46279e0b0c3c5fa9cc108d9ea9
7
- data.tar.gz: 119f36efa5cbcd455e5fceeafbd9e5abcbd421f1cc7d9a729ad0329052818280d038f7ec40430750be4495f8526398471e0c3a8e07165638a4cbef0e936a8190
6
+ metadata.gz: 30324cb47f48fafc2d04956a24f06c1cc11d9a701a2697cd3f612c76bcdf267c094bbef0287d0750061a9fd99d597fb6335ee1878ea3343a16d62fb79d84edf0
7
+ data.tar.gz: 7add1f7a89ffec976363278700f8be9333803cbca7b2a619b9c466898b9de895a0b7692cf04d0490b042fec386561a13a0e7c1a355c2f16199aa1d92d7342bc1
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # MultiOpQueue
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/multi_op_queue`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Delete this and the text above, and describe your gem
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
- TODO: Write usage instructions here
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
 
@@ -1,3 +1,3 @@
1
1
  module MultiOpQueue
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -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.0
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-14 00:00:00.000000000 Z
11
+ date: 2016-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler