@@ -15,47 +15,36 @@ class ProcessManager
15
15
*/
16
16
const THREADS_COUNT = 'MAGE_INDEXER_THREADS_COUNT ' ;
17
17
18
- /**
19
- * Configuration path for threads count
20
- */
21
- const THREADS_COUNT_CONFIG_PATH = 'indexer/threads_count ' ;
22
-
23
18
/** @var bool */
24
19
private $ failInChildProcess = false ;
25
20
26
21
/** @var \Magento\Framework\App\ResourceConnection */
27
22
private $ resource ;
28
23
29
- /** @var \Magento\Framework\App\DeploymentConfig */
30
- private $ deploymentConfig ;
31
-
32
24
/** @var \Magento\Framework\Registry */
33
25
private $ registry ;
34
26
35
27
/** @var int|null */
36
- private $ threadsCountFromEnvVariable ;
28
+ private $ threadsCount ;
37
29
38
30
/**
39
31
* @param \Magento\Framework\App\ResourceConnection $resource
40
- * @param \Magento\Framework\App\DeploymentConfig $deploymentConfig
41
32
* @param \Magento\Framework\Registry $registry
42
33
* @param int|null $threadsCount
43
34
*/
44
35
public function __construct (
45
36
\Magento \Framework \App \ResourceConnection $ resource ,
46
- \Magento \Framework \App \DeploymentConfig $ deploymentConfig ,
47
37
\Magento \Framework \Registry $ registry = null ,
48
38
int $ threadsCount = null
49
39
) {
50
40
$ this ->resource = $ resource ;
51
- $ this ->deploymentConfig = $ deploymentConfig ;
52
41
if (null === $ registry ) {
53
42
$ registry = \Magento \Framework \App \ObjectManager::getInstance ()->get (
54
43
\Magento \Framework \Registry::class
55
44
);
56
45
}
57
46
$ this ->registry = $ registry ;
58
- $ this ->threadsCountFromEnvVariable = $ threadsCount ;
47
+ $ this ->threadsCount = $ threadsCount ;
59
48
}
60
49
61
50
/**
@@ -65,7 +54,7 @@ public function __construct(
65
54
*/
66
55
public function execute ($ userFunctions )
67
56
{
68
- if ($ this ->getThreadsCount () > 1 && $ this ->isCanBeParalleled () && !$ this ->isSetupMode () && PHP_SAPI == 'cli ' ) {
57
+ if ($ this ->threadsCount > 1 && $ this ->isCanBeParalleled () && !$ this ->isSetupMode () && PHP_SAPI == 'cli ' ) {
69
58
$ this ->multiThreadsExecute ($ userFunctions );
70
59
} else {
71
60
$ this ->simpleThreadExecute ($ userFunctions );
@@ -123,22 +112,6 @@ private function isCanBeParalleled()
123
112
return function_exists ('pcntl_fork ' );
124
113
}
125
114
126
- /**
127
- * Get threads count
128
- *
129
- * @return bool
130
- */
131
- private function getThreadsCount ()
132
- {
133
- if ($ this ->threadsCountFromEnvVariable !== null ) {
134
- return (int )$ this ->threadsCountFromEnvVariable ;
135
- }
136
- if ($ this ->deploymentConfig ->get (self ::THREADS_COUNT_CONFIG_PATH ) !== null ) {
137
- return (int )$ this ->deploymentConfig ->get (self ::THREADS_COUNT_CONFIG_PATH );
138
- }
139
- return 1 ;
140
- }
141
-
142
115
/**
143
116
* Is setup mode
144
117
*
@@ -170,7 +143,7 @@ private function startChildProcess($userFunction)
170
143
private function executeParentProcess (&$ threadNumber )
171
144
{
172
145
$ threadNumber ++;
173
- if ($ threadNumber >= $ this ->getThreadsCount () ) {
146
+ if ($ threadNumber >= $ this ->threadsCount ) {
174
147
pcntl_wait ($ status );
175
148
if (pcntl_wexitstatus ($ status ) !== 0 ) {
176
149
$ this ->failInChildProcess = true ;
0 commit comments