Skip to content

Commit 048f5d0

Browse files
bensheldoneregon
authored andcommitted
ThreadPoolExecutor kill will wait_for_termination in JRuby; ensure TimerSet timer thread shuts down cleanly
1 parent 4e340ed commit 048f5d0

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

‎lib/concurrent-ruby/concurrent/executor/java_executor_service.rb‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def shutdown
4646
defkill
4747
synchronizedo
4848
@executor.shutdownNow
49+
wait_for_termination
4950
nil
5051
end
5152
end

‎lib/concurrent-ruby/concurrent/executor/timer_set.rb‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def post(delay, *args, &task)
6161
# not running.
6262
defkill
6363
shutdown
64+
@timer_executor.kill
6465
end
6566

6667
private:<<
@@ -122,7 +123,9 @@ def remove_task(task)
122123
defns_shutdown_execution
123124
ns_reset_if_forked
124125
@queue.clear
125-
@timer_executor.kill
126+
@condition.set
127+
@condition.reset
128+
@timer_executor.shutdown
126129
stopped_event.set
127130
end
128131

‎spec/concurrent/executor/timer_set_spec.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ module Concurrent
244244
expect(task.schedule_time).toeqexpected
245245
end
246246

247-
it'reschdules a pending and unpost task when given a valid time'do
247+
it'reschedules a pending and unpost task when given a valid time'do
248248
initial_delay=10
249249
rescheduled_delay=20
250250
task=subject.post(initial_delay){nil}

0 commit comments

Comments
(0)