resque-durable 4.0.1 → 4.1.0

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: 06e9f2c661904146837eb00fb32749a8b98f97d5b0823ade9f4d5728415dd296
4
+ data.tar.gz: 65eb84b6a2cde6fd3aaafe3bee4168a61ab8bfb1837f01b61759f9895970adf9
5
5
  SHA512:
6
- metadata.gz: 19359e3f24e9971bdc5c94ab4a173e09dc1895396281ad60f45c99bf6e43b9db4924a66d5c7f076d50e4d531db8ae48ff6b10793332f7a330c4ac71467769b91
7
- data.tar.gz: 664bc54e4360bed1a9180987f779f904fac47177955b3a4c196ac750c1dda03303f6d90eb3f3bcadac035c14cf81b7f286f1265f0da645a7443fd4625e2a8d95
6
+ metadata.gz: 2fa7e0802df25c44b81a8e38ac019a33a3479d08fbeed792204d8d1e173618cbe898d45ae08f0b3abf43e9018d831b07207b47740b5fc3ae369a2b55f94739a8
7
+ data.tar.gz: 5c90519a2aaee23758d39d0cab29d6108a8b0d639b4ba151b003ee0e5b2e9c0f95a4628a5a973124091b33f0ae66415884552b9807143481c7e1b53984c69b56
@@ -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.1.0
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-06-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '5.1'
20
+ version: '5.2'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '5.1'
27
+ version: '5.2'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: resque
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -67,118 +67,6 @@ dependencies:
67
67
  - - "<"
68
68
  - !ruby/object:Gem::Version
69
69
  version: '5'
70
- - !ruby/object:Gem::Dependency
71
- name: bump
72
- requirement: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- version: '0'
77
- type: :development
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- version: '0'
84
- - !ruby/object:Gem::Dependency
85
- name: rake
86
- requirement: !ruby/object:Gem::Requirement
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- version: '0'
91
- type: :development
92
- prerelease: false
93
- version_requirements: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - ">="
96
- - !ruby/object:Gem::Version
97
- version: '0'
98
- - !ruby/object:Gem::Dependency
99
- name: minitest
100
- requirement: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- version: '0'
105
- type: :development
106
- prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
111
- version: '0'
112
- - !ruby/object:Gem::Dependency
113
- name: minitest-rg
114
- requirement: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - ">="
117
- - !ruby/object:Gem::Version
118
- version: '0'
119
- type: :development
120
- prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
122
- requirements:
123
- - - ">="
124
- - !ruby/object:Gem::Version
125
- version: '0'
126
- - !ruby/object:Gem::Dependency
127
- name: mocha
128
- requirement: !ruby/object:Gem::Requirement
129
- requirements:
130
- - - ">="
131
- - !ruby/object:Gem::Version
132
- version: '0'
133
- type: :development
134
- prerelease: false
135
- version_requirements: !ruby/object:Gem::Requirement
136
- requirements:
137
- - - ">="
138
- - !ruby/object:Gem::Version
139
- version: '0'
140
- - !ruby/object:Gem::Dependency
141
- name: timecop
142
- requirement: !ruby/object:Gem::Requirement
143
- requirements:
144
- - - ">="
145
- - !ruby/object:Gem::Version
146
- version: '0'
147
- type: :development
148
- prerelease: false
149
- version_requirements: !ruby/object:Gem::Requirement
150
- requirements:
151
- - - ">="
152
- - !ruby/object:Gem::Version
153
- version: '0'
154
- - !ruby/object:Gem::Dependency
155
- name: pry
156
- requirement: !ruby/object:Gem::Requirement
157
- requirements:
158
- - - ">="
159
- - !ruby/object:Gem::Version
160
- version: '0'
161
- type: :development
162
- prerelease: false
163
- version_requirements: !ruby/object:Gem::Requirement
164
- requirements:
165
- - - ">="
166
- - !ruby/object:Gem::Version
167
- version: '0'
168
- - !ruby/object:Gem::Dependency
169
- name: sqlite3
170
- requirement: !ruby/object:Gem::Requirement
171
- requirements:
172
- - - ">="
173
- - !ruby/object:Gem::Version
174
- version: '0'
175
- type: :development
176
- prerelease: false
177
- version_requirements: !ruby/object:Gem::Requirement
178
- requirements:
179
- - - ">="
180
- - !ruby/object:Gem::Version
181
- version: '0'
182
70
  description:
183
71
  email:
184
72
  executables: []
@@ -202,7 +90,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
202
90
  requirements:
203
91
  - - ">="
204
92
  - !ruby/object:Gem::Version
205
- version: '2.6'
93
+ version: '2.7'
206
94
  required_rubygems_version: !ruby/object:Gem::Requirement
207
95
  requirements:
208
96
  - - ">="