resque-durable 4.0.1 → 4.0.3

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
  SHA256:
3
- metadata.gz: 8e7c7fff3b8211d05ed222ff295905eb61c7a9444b3bb029c2c74021582cb38c
4
- data.tar.gz: e58f19b071c60f27a46adca8f7b7149ec046ee448e13d44b13a67b39b7dc2849
3
+ metadata.gz: 494eb6a3c9e764eb8399ab674687afee948298b85d06c2c7944815762dc0bf9d
4
+ data.tar.gz: 7be3da9c71fa28a34f2c02d4f56e931b8ca4b3b9c5fd9048682ffa9a3c5ccfcb
5
5
  SHA512:
6
- metadata.gz: 19359e3f24e9971bdc5c94ab4a173e09dc1895396281ad60f45c99bf6e43b9db4924a66d5c7f076d50e4d531db8ae48ff6b10793332f7a330c4ac71467769b91
7
- data.tar.gz: 664bc54e4360bed1a9180987f779f904fac47177955b3a4c196ac750c1dda03303f6d90eb3f3bcadac035c14cf81b7f286f1265f0da645a7443fd4625e2a8d95
6
+ metadata.gz: e8ae872c2984e06a425167756ec665704b6134a84f854caeb0e069dfe5fa8593370b4fead874901cad9a84c2efeb07675134b01e8006164161dd50614f8018ed
7
+ data.tar.gz: 599622efbb0b65267558adc279b8431f640fd1fc50f0db3fcc23547ff1b852ebdf28bfd0b4f12744b3a038e81ff9cd6a56cf492025ba8bfb247d72473dc129cb
@@ -11,6 +11,7 @@ module Resque
11
11
  @last_timeout = nil
12
12
  @interval = interval
13
13
  @mutex = Mutex.new
14
+ @cv = ConditionVariable.new
14
15
  @stop = false
15
16
  @thread = nil
16
17
  end
@@ -51,7 +52,11 @@ module Resque
51
52
  heartbeat!
52
53
 
53
54
  @mutex.synchronize do
54
- @mutex.sleep(@interval)
55
+ end_at = monotonic_now + @interval
56
+ while !@stop && monotonic_now < end_at
57
+ sleep_for = end_at - monotonic_now
58
+ @cv.wait(@mutex, sleep_for)
59
+ end
55
60
  end
56
61
  end
57
62
  end
@@ -59,12 +64,9 @@ module Resque
59
64
 
60
65
  def stop_and_wait!
61
66
  return unless @thread
67
+ signal_stop!
62
68
  # Prevent deadlock if called by the `heartbeat` thread, which can't wait for itself to die.
63
- return signal_stop! if @thread == Thread.current
64
- while @thread.alive?
65
- signal_stop!
66
- sleep 0.01
67
- end
69
+ return if @thread == Thread.current
68
70
  @thread.join
69
71
  @thread = nil
70
72
  end
@@ -74,9 +76,15 @@ module Resque
74
76
  return unless @thread
75
77
  @mutex.synchronize do
76
78
  @stop = true
77
- @thread.wakeup
79
+ @cv.broadcast
78
80
  end
79
81
  end
82
+
83
+ private
84
+
85
+ def monotonic_now
86
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
87
+ end
80
88
  end
81
89
  end
82
90
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-durable
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Chapweske
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-01-19 00:00:00.000000000 Z
12
+ date: 2023-02-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord