File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -68,10 +68,27 @@ def auto_terminate?
68
68
69
69
def enable_at_exit_handler! ( opts = { } )
70
70
if opts . fetch ( :stop_on_exit , true )
71
- # without this the application may fail to exit
72
71
@auto_terminate = true
73
- this = self
74
- at_exit { this . kill if Concurrent . auto_terminate_all_executors? }
72
+ if RUBY_PLATFORM == 'java'
73
+ create_java_at_exit_handler! ( self )
74
+ else
75
+ create_ruby_at_exit_handler! ( self . object_id )
76
+ end
77
+ end
78
+ end
79
+
80
+ def create_ruby_at_exit_handler! ( id )
81
+ at_exit do
82
+ if Concurrent . auto_terminate_all_executors?
83
+ this = ObjectSpace . _id2ref ( id )
84
+ this . kill if this
85
+ end
86
+ end
87
+ end
88
+
89
+ def create_java_at_exit_handler! ( this )
90
+ at_exit do
91
+ this . kill if Concurrent . auto_terminate_all_executors?
75
92
end
76
93
end
77
94
end
You can’t perform that action at this time.
0 commit comments