multi_op_queue 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/multi_op_queue.rb +11 -2
- data/lib/multi_op_queue/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2aafd43910b87eca98e148c99c6df5664b3834ea
|
4
|
+
data.tar.gz: 9a4407fbc1fb19f3e7b5a667401ca19c0310d3e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 548c845961b3ab2ec2b4ede603e6df84211020d5a1887f80b679c814a333e628feab8395406d6b7d8933158ab4b3d0b778b92f47a0b24c9ee204dcb0b28abba8
|
7
|
+
data.tar.gz: 30fe3e620a3660126aaefdcd85f55291306a013d0b3b7b05994cc784bf8a86eeed58e220942598cf598f48ab285f2db47b2aaa026b532b36952d0849331af676
|
data/lib/multi_op_queue.rb
CHANGED
@@ -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,
|
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
|
143
|
+
@cond.wait(@mutex, timeout)
|
144
|
+
return nil if @que.empty?
|
136
145
|
ensure
|
137
146
|
@num_waiting -= 1
|
138
147
|
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.
|
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:
|
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.
|
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
|