@@ -41,15 +41,15 @@ private function getMaxCpuUsage(): int {
4141 return $ this ->max_cpu_count ??= (isset ($ _SERVER ['PARALLEL_MAX_COUNT ' ]) ? (int ) $ _SERVER ['PARALLEL_MAX_COUNT ' ] : cpu_count ( (float ) ($ _SERVER ['PARALLEL_MAX_PERCENT ' ] ?? 1.0 ) ));
4242 }
4343
44- protected function setMaxCpuCountUsage (int $ count ): int {
44+ private function setMaxCpuCountUsage (int $ count ): int {
4545 return $ this ->send ($ this ->max_cpu_count = $ count );
4646 }
4747
48- protected function setMaxCpuPercentageUsage (float $ percentage ): int {
48+ private function setMaxCpuPercentageUsage (float $ percentage ): int {
4949 return $ this ->send ($ this ->max_cpu_count = max (1 , cpu_count ($ percentage )));
5050 }
5151
52- protected function getRegisteredWorker (string $ worker ): RegisteredWorker | false {
52+ private function getRegisteredWorker (string $ worker ): RegisteredWorker | false {
5353 if ( !array_key_exists ($ worker , $ this ->workers_hashmap )) {
5454 return $ this ->send (false );
5555 }
@@ -59,7 +59,7 @@ protected function getRegisteredWorker(string $worker): RegisteredWorker | false
5959 ->send ($ this ->getSelectedWorker ());
6060 }
6161
62- protected function registerWorker (string | Closure $ worker , array $ args = []): RegisteredWorker {
62+ private function registerWorker (string | Closure $ worker , array $ args = []): RegisteredWorker {
6363 // check if worker is already registered
6464 if (is_string ($ worker ) && array_key_exists ($ worker , $ this ->workers_hashmap )) {
6565 throw new WorkerAlreadyDefinedException ($ worker );
@@ -80,7 +80,7 @@ protected function registerWorker(string | Closure $worker, array $args = []): R
8080 ->send ($ registered_worker );
8181 }
8282
83- protected function queueTask (array $ data ): int {
83+ private function queueTask (array $ data ): int {
8484 if (null === $ worker = $ this ->getSelectedWorker ()) {
8585 // reject task scheduling, no worker is defined
8686 throw new NoWorkerDefinedException ;
@@ -110,7 +110,7 @@ protected function queueTask(array $data): int {
110110 return $ this ->send ($ task ->getIdentifier ());
111111 }
112112
113- protected function getTasks (): array | false {
113+ private function getTasks (): array | false {
114114 if ( !PARALLEL_EXT_LOADED ) {
115115 return $ this ->tasks ;
116116 }
@@ -123,7 +123,7 @@ protected function getTasks(): array | false {
123123 return false ;
124124 }
125125
126- protected function removeTask (int $ task_id ): bool {
126+ private function removeTask (int $ task_id ): bool {
127127 // remove it from pending tasks
128128 if (array_key_exists ($ task_id , $ this ->pending_tasks )) {
129129 unset($ this ->pending_tasks [$ task_id ]);
@@ -148,7 +148,7 @@ protected function removeTask(int $task_id): bool {
148148 return $ this ->send (false );
149149 }
150150
151- protected function removeAllTasks (): bool {
151+ private function removeAllTasks (): bool {
152152 $ this ->stopRunningTasks ();
153153
154154 $ this ->tasks = [];
@@ -157,14 +157,14 @@ protected function removeAllTasks(): bool {
157157 return $ this ->send (true );
158158 }
159159
160- protected function removePendingTasks (): bool {
160+ private function removePendingTasks (): bool {
161161 // clear pending tasks
162162 $ this ->pending_tasks = [];
163163
164164 return $ this ->send (true );
165165 }
166166
167- protected function stopRunningTasks (bool $ should_return = false ): bool {
167+ private function stopRunningTasks (bool $ should_return = false ): bool {
168168 // kill all running threads
169169 foreach ($ this ->running_tasks as $ task_id => $ running_task ) {
170170 // check if future is already done working
@@ -197,7 +197,7 @@ protected function stopRunningTasks(bool $should_return = false): bool {
197197 return true ;
198198 }
199199
200- protected function enableProgressBar (string $ worker_id , int $ steps ): bool {
200+ private function enableProgressBar (string $ worker_id , int $ steps ): bool {
201201 if ( !array_key_exists ($ worker_id , $ this ->workers_hashmap )) {
202202 throw new WorkerNotDefinedException ;
203203 }
@@ -218,7 +218,7 @@ protected function enableProgressBar(string $worker_id, int $steps): bool {
218218 return $ this ->send (true );
219219 }
220220
221- protected function update (): void {
221+ private function update (): void {
222222 $ this ->cleanFinishedTasks ();
223223 while ($ this ->hasCpuAvailable () && $ this ->hasPendingTasks ()) {
224224 $ this ->startNextPendingTask ();
@@ -235,7 +235,7 @@ protected function update(): void {
235235 }
236236 }
237237
238- protected function await (?int $ wait_until = null ): bool {
238+ private function await (?int $ wait_until = null ): bool {
239239 if (PARALLEL_EXT_LOADED ) {
240240 return $ this ->send (time () <= ($ wait_until ?? time ()) && ($ this ->hasPendingTasks () || $ this ->hasRunningTasks ()));
241241 }
0 commit comments