multi_op_queue 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ef55a4124c3c6e194ed0bfb384a1e8f6544c9671
4
- data.tar.gz: 455219fe3fd38645190290add52e0fdcc61fb48d
3
+ metadata.gz: 2aafd43910b87eca98e148c99c6df5664b3834ea
4
+ data.tar.gz: 9a4407fbc1fb19f3e7b5a667401ca19c0310d3e8
5
5
  SHA512:
6
- metadata.gz: 81fc3d578c73a4d68a8bba00f9bc6838bdfbd281743140d1d9e4b5a80946f7393ba660cb602923ef10b7f5d4f3e1e8330517dc5318ddfee0a61f860919b96b08
7
- data.tar.gz: 1b39214e29bfc75e55be0f67a15264622a18d367e5f4551a765f85ee3768c70307656c776583db29db085493b1fe06aef1f2c602b9f812f0282ab1ef075f6b76
6
+ metadata.gz: 548c845961b3ab2ec2b4ede603e6df84211020d5a1887f80b679c814a333e628feab8395406d6b7d8933158ab4b3d0b778b92f47a0b24c9ee204dcb0b28abba8
7
+ data.tar.gz: 30fe3e620a3660126aaefdcd85f55291306a013d0b3b7b05994cc784bf8a86eeed58e220942598cf598f48ab285f2db47b2aaa026b532b36952d0849331af676
@@ -122,7 +122,15 @@ module MultiOpQueue
122
122
  # suspended until data is pushed onto the queue. If +non_block+ is true, the
123
123
  # thread isn't suspended, and an exception is raised.
124
124
  #
125
- def pop_up_to(num_to_pop = 1, non_block=false)
125
+ def pop_up_to(num_to_pop = 1, opts = {})
126
+ case opts
127
+ when TrueClass, FalseClass
128
+ non_bock = opts
129
+ when Hash
130
+ timeout = opts.fetch(:timeout, nil)
131
+ non_block = opts.fetch(:non_block, false)
132
+ end
133
+
126
134
  handle_interrupt do
127
135
  @mutex.synchronize do
128
136
  while true
@@ -132,7 +140,8 @@ module MultiOpQueue
132
140
  else
133
141
  begin
134
142
  @num_waiting += 1
135
- @cond.wait @mutex
143
+ @cond.wait(@mutex, timeout)
144
+ return nil if @que.empty?
136
145
  ensure
137
146
  @num_waiting -= 1
138
147
  end
@@ -1,3 +1,3 @@
1
1
  module MultiOpQueue
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
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.2
4
+ version: 0.2.0
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-16 00:00:00.000000000 Z
11
+ date: 2017-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  version: '0'
119
119
  requirements: []
120
120
  rubyforge_project:
121
- rubygems_version: 2.5.1
121
+ rubygems_version: 2.6.13
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: allow multi-op calls on Queue while holding lock