@@ -10,34 +10,115 @@ module Concurrent
10
10
11
11
# initialize the global executors
12
12
class << self
13
+
14
+ # @!visibility private
13
15
@@auto_terminate_global_executors = Concurrent ::AtomicBoolean . new ( true )
14
16
17
+ # @!visibility private
18
+ @@auto_terminate_all_executors = Concurrent ::AtomicBoolean . new ( true )
19
+
20
+ # @!visibility private
15
21
@@global_fast_executor = LazyReference . new do
16
22
Concurrent . new_fast_executor (
17
23
stop_on_exit : @@auto_terminate_global_executors . value )
18
24
end
19
25
26
+ # @!visibility private
20
27
@@global_io_executor = LazyReference . new do
21
28
Concurrent . new_io_executor (
22
29
stop_on_exit : @@auto_terminate_global_executors . value )
23
30
end
24
31
32
+ # @!visibility private
25
33
@@global_timer_set = LazyReference . new do
26
34
Concurrent ::TimerSet . new (
27
35
stop_on_exit : @@auto_terminate_global_executors . value )
28
36
end
29
37
end
30
38
31
- # defines if executors should be auto-terminated with `at_exit` callback
39
+ # Defines if global executors should be auto-terminated with an
40
+ # `at_exit` callback. When set to `false` it will be the application
41
+ # programmer's responsibility to ensure that the global thread pools
42
+ # are shutdown properly prior to application exit.
43
+ #
44
+ # @note Only change this option if you know what you are doing!
45
+ # When this is set to true (the default) then `at_exit` handlers
46
+ # will be registered automatically for the *global* thread pools
47
+ # to ensure that they are shutdown when the application ends. When
48
+ # changed to false, the `at_exit` handlers will be circumvented
49
+ # for all *global* thread pools. This method should *never* be called
50
+ # from within a gem. It should *only* be used from within the main
51
+ # application and even then it should be used only when necessary.
52
+ #
32
53
def self . disable_auto_termination_of_global_executors!
33
54
@@auto_terminate_global_executors . make_false
34
55
end
35
56
36
- # defines if executors should be auto-terminated with `at_exit` callback
57
+ # Defines if global executors should be auto-terminated with an
58
+ # `at_exit` callback. When set to `false` it will be the application
59
+ # programmer's responsibility to ensure that the global thread pools
60
+ # are shutdown properly prior to application exit.
61
+ #
62
+ # @note Only change this option if you know what you are doing!
63
+ # When this is set to true (the default) then `at_exit` handlers
64
+ # will be registered automatically for the *global* thread pools
65
+ # to ensure that they are shutdown when the application ends. When
66
+ # changed to false, the `at_exit` handlers will be circumvented
67
+ # for all *global* thread pools. This method should *never* be called
68
+ # from within a gem. It should *only* be used from within the main
69
+ # application and even then it should be used only when necessary.
70
+ #
71
+ # @return [Boolean] true when global thread pools will auto-terminate on
72
+ # application exit using an `at_exit` handler; false when no auto-termination
73
+ # will occur.
37
74
def self . auto_terminate_global_executors?
38
75
@@auto_terminate_global_executors . value
39
76
end
40
77
78
+ # Defines if *ALL* executors should be auto-terminated with an
79
+ # `at_exit` callback. When set to `false` it will be the application
80
+ # programmer's responsibility to ensure that *all* thread pools,
81
+ # including the global thread pools, are shutdown properly prior to
82
+ # application exit.
83
+ #
84
+ # @note Only change this option if you know what you are doing!
85
+ # When this is set to true (the default) then `at_exit` handlers
86
+ # will be registered automatically for *all* thread pools to
87
+ # ensure that they are shutdown when the application ends. When
88
+ # changed to false, the `at_exit` handlers will be circumvented
89
+ # for *all* Concurrent Ruby thread pools running within the
90
+ # application. Even those created within other gems used by the
91
+ # application. This method should *never* be called from within a
92
+ # gem. It should *only* be used from within the main application.
93
+ # And even then it should be used only when necessary.
94
+ def self . disable_auto_termination_of_all_executors!
95
+ @@auto_terminate_all_executors . make_false
96
+ end
97
+
98
+ # Defines if *ALL* executors should be auto-terminated with an
99
+ # `at_exit` callback. When set to `false` it will be the application
100
+ # programmer's responsibility to ensure that *all* thread pools,
101
+ # including the global thread pools, are shutdown properly prior to
102
+ # application exit.
103
+ #
104
+ # @note Only change this option if you know what you are doing!
105
+ # When this is set to true (the default) then `at_exit` handlers
106
+ # will be registered automatically for *all* thread pools to
107
+ # ensure that they are shutdown when the application ends. When
108
+ # changed to false, the `at_exit` handlers will be circumvented
109
+ # for *all* Concurrent Ruby thread pools running within the
110
+ # application. Even those created within other gems used by the
111
+ # application. This method should *never* be called from within a
112
+ # gem. It should *only* be used from within the main application.
113
+ # And even then it should be used only when necessary.
114
+ #
115
+ # @return [Boolean] true when *all* thread pools will auto-terminate on
116
+ # application exit using an `at_exit` handler; false when no auto-termination
117
+ # will occur.
118
+ def self . auto_terminate_all_executors?
119
+ @@auto_terminate_all_executors . value
120
+ end
121
+
41
122
# Global thread pool optimized for short, fast *operations*.
42
123
#
43
124
# @return [ThreadPoolExecutor] the thread pool
0 commit comments