resque-durable 4.0.0 → 4.0.3

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
  SHA256:
3
- metadata.gz: 3928943d5910f0175a2b2155b5bd417bde192e894448a53da76b184c610846b3
4
- data.tar.gz: 95a94e3dd8d3c8bddb94ec48739fd2f5f9619c1e63cf497dce3fbe71ccfb1996
3
+ metadata.gz: 494eb6a3c9e764eb8399ab674687afee948298b85d06c2c7944815762dc0bf9d
4
+ data.tar.gz: 7be3da9c71fa28a34f2c02d4f56e931b8ca4b3b9c5fd9048682ffa9a3c5ccfcb
5
5
  SHA512:
6
- metadata.gz: 1d11f968ff7957ed51e96857eafe86ed406152b44a7d9664568eec72a7f0095fca0f08715f6a2b7717cae3c417e0fc85dc9ed352394b560c99678c7137796085
7
- data.tar.gz: a2e612f1cbcaf5b00246526ff5160203e2596aaa61cd27cddadb1e09b1692a6a4c8e08c3a3ac14ac986615334b2d4b8a5a59ec379a3f75a39c51f5523ec1449c
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
@@ -77,7 +77,7 @@ module Resque
77
77
  end
78
78
 
79
79
  def enqueue
80
- job_klass.enqueue(*(payload.push(self)))
80
+ job_klass.enqueue(*(payload.push(becomes(job_klass.auditor))))
81
81
  end
82
82
 
83
83
  def duration
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.0
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: 2022-09-28 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