@@ -14,28 +14,8 @@ class Configuration
1414
1515 # Create a new configuration object.
1616 def initialize
17- @cores = Concurrent ::processor_count
18-
19- @global_task_pool = Delay . new do
20- Concurrent ::ThreadPoolExecutor . new (
21- min_threads : [ 2 , @cores ] . max ,
22- max_threads : [ 20 , @cores * 15 ] . max ,
23- idletime : 2 * 60 , # 2 minutes
24- max_queue : 0 , # unlimited
25- overflow_policy : :abort # raise an exception
26- )
27- end
28-
29- @global_operation_pool = Delay . new do
30- Concurrent ::ThreadPoolExecutor . new (
31- min_threads : [ 2 , @cores ] . max ,
32- max_threads : [ 2 , @cores ] . max ,
33- idletime : 10 * 60 , # 10 minutes
34- max_queue : [ 20 , @cores * 15 ] . max ,
35- overflow_policy : :abort # raise an exception
36- )
37- end
38-
17+ @global_task_pool = Delay . new { new_task_pool }
18+ @global_operation_pool = Delay . new { new_operation_pool }
3919 @global_timer_set = Delay . new { Concurrent ::TimerSet . new }
4020 end
4121
@@ -99,6 +79,26 @@ def global_operation_pool=(executor)
9979 @global_operation_pool . reconfigure { executor } or
10080 raise ConfigurationError . new ( 'global operation pool was already set' )
10181 end
82+
83+ def new_task_pool
84+ Concurrent ::ThreadPoolExecutor . new (
85+ min_threads : [ 2 , Concurrent . processor_count ] . max ,
86+ max_threads : [ 20 , Concurrent . processor_count * 15 ] . max ,
87+ idletime : 2 * 60 , # 2 minutes
88+ max_queue : 0 , # unlimited
89+ overflow_policy : :abort # raise an exception
90+ )
91+ end
92+
93+ def new_operation_pool
94+ Concurrent ::ThreadPoolExecutor . new (
95+ min_threads : [ 2 , Concurrent . processor_count ] . max ,
96+ max_threads : [ 2 , Concurrent . processor_count ] . max ,
97+ idletime : 10 * 60 , # 10 minutes
98+ max_queue : [ 20 , Concurrent . processor_count * 15 ] . max ,
99+ overflow_policy : :abort # raise an exception
100+ )
101+ end
102102 end
103103
104104 # create the default configuration on load
0 commit comments