multi_op_queue 0.1.1 → 0.1.2

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: 6e7e8948258b342529f1d42f0cac55b83f5a2d62
4
- data.tar.gz: 70af985eebf916e51ab87b06dddd240c1e74bae6
3
+ metadata.gz: ef55a4124c3c6e194ed0bfb384a1e8f6544c9671
4
+ data.tar.gz: 455219fe3fd38645190290add52e0fdcc61fb48d
5
5
  SHA512:
6
- metadata.gz: 30324cb47f48fafc2d04956a24f06c1cc11d9a701a2697cd3f612c76bcdf267c094bbef0287d0750061a9fd99d597fb6335ee1878ea3343a16d62fb79d84edf0
7
- data.tar.gz: 7add1f7a89ffec976363278700f8be9333803cbca7b2a619b9c466898b9de895a0b7692cf04d0490b042fec386561a13a0e7c1a355c2f16199aa1d92d7342bc1
6
+ metadata.gz: 81fc3d578c73a4d68a8bba00f9bc6838bdfbd281743140d1d9e4b5a80946f7393ba660cb602923ef10b7f5d4f3e1e8330517dc5318ddfee0a61f860919b96b08
7
+ data.tar.gz: 1b39214e29bfc75e55be0f67a15264622a18d367e5f4551a765f85ee3768c70307656c776583db29db085493b1fe06aef1f2c602b9f812f0282ab1ef075f6b76
@@ -1,3 +1,3 @@
1
1
  module MultiOpQueue
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -47,7 +47,7 @@ module MultiOpQueue
47
47
  # Concatenates +ary+ onto the queue.
48
48
  #
49
49
  def concat(ary)
50
- Thread.handle_interrupt(StandardError => :on_blocking) do
50
+ handle_interrupt do
51
51
  @mutex.synchronize do
52
52
  @que.concat ary
53
53
  @cond.signal
@@ -59,7 +59,7 @@ module MultiOpQueue
59
59
  # Pushes +obj+ to the queue.
60
60
  #
61
61
  def push(obj)
62
- Thread.handle_interrupt(StandardError => :on_blocking) do
62
+ handle_interrupt do
63
63
  @mutex.synchronize do
64
64
  @que.push obj
65
65
  @cond.signal
@@ -83,7 +83,7 @@ module MultiOpQueue
83
83
  # thread isn't suspended, and an exception is raised.
84
84
  #
85
85
  def pop(non_block=false)
86
- Thread.handle_interrupt(StandardError => :on_blocking) do
86
+ handle_interrupt do
87
87
  @mutex.synchronize do
88
88
  while true
89
89
  if @que.empty?
@@ -123,7 +123,7 @@ module MultiOpQueue
123
123
  # thread isn't suspended, and an exception is raised.
124
124
  #
125
125
  def pop_up_to(num_to_pop = 1, non_block=false)
126
- Thread.handle_interrupt(StandardError => :on_blocking) do
126
+ handle_interrupt do
127
127
  @mutex.synchronize do
128
128
  while true
129
129
  if @que.empty?
@@ -177,5 +177,19 @@ module MultiOpQueue
177
177
  def num_waiting
178
178
  @num_waiting
179
179
  end
180
+
181
+ private
182
+
183
+ def handle_interrupt
184
+ @handle_interrupt = Thread.respond_to?(:handle_interrupt) if @handle_interrupt.nil?
185
+
186
+ if @handle_interrupt
187
+ Thread.handle_interrupt(StandardError => :on_blocking) do
188
+ yield
189
+ end
190
+ else
191
+ yield
192
+ end
193
+ end
180
194
  end
181
195
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multi_op_queue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Dewitt