@@ -256,6 +256,16 @@ def timeout_interval=(value)
256
256
warn 'TimerTask timeouts are now ignored as these were not able to be implemented correctly'
257
257
end
258
258
259
+ def shutdown
260
+ @task . cancel if @task # must happen outside of synchronization
261
+ super
262
+ end
263
+
264
+ def kill
265
+ @task . cancel if @task # must happen outside of synchronization
266
+ super
267
+ end
268
+
259
269
private :post , :<<
260
270
261
271
private
@@ -270,6 +280,7 @@ def ns_initialize(opts, &task)
270
280
@run_now = opts [ :now ] || opts [ :run_now ]
271
281
@executor = Concurrent ::SafeTaskExecutor . new ( task )
272
282
@running = Concurrent ::AtomicBoolean . new ( false )
283
+ @task = nil
273
284
@value = nil
274
285
275
286
self . observers = Collection ::CopyOnNotifyObserverSet . new
@@ -278,26 +289,24 @@ def ns_initialize(opts, &task)
278
289
# @!visibility private
279
290
def ns_shutdown_execution
280
291
@running . make_false
281
- @running = Concurrent ::AtomicBoolean . new ( false )
282
292
super
283
293
end
284
294
285
295
# @!visibility private
286
296
def ns_kill_execution
287
297
@running . make_false
288
- @running = Concurrent ::AtomicBoolean . new ( false )
289
298
super
290
299
end
291
300
292
301
# @!visibility private
293
302
def schedule_next_task ( interval = execution_interval )
294
- ScheduledTask . execute ( interval , args : [ Concurrent ::Event . new , @running ] , &method ( :execute_task ) )
303
+ @task = ScheduledTask . execute ( interval , args : [ Concurrent ::Event . new ] , &method ( :execute_task ) )
295
304
nil
296
305
end
297
306
298
307
# @!visibility private
299
- def execute_task ( completion , continue_running )
300
- return nil unless continue_running . true?
308
+ def execute_task ( completion )
309
+ return nil unless @running . true?
301
310
_success , value , reason = @executor . execute ( self )
302
311
if completion . try?
303
312
self . value = value
0 commit comments