1111class Async
1212{
1313 /** @var TaskInterface[] */
14- private array $ pendingQueue = [];
14+ protected array $ pendingQueue = [];
1515
1616 /** @var TaskInterface[] */
17- private array $ progressQueue = [];
17+ protected array $ progressQueue = [];
1818
1919 /** @var TaskInterface[] */
20- private array $ finishedQueue = [];
20+ protected array $ finishedQueue = [];
2121
2222 /** @var TaskInterface[] */
23- private array $ failedQueue = [];
23+ protected array $ failedQueue = [];
2424
2525 /** @var TaskFactoryInterface */
26- private TaskFactoryInterface $ taskFactory ;
26+ protected TaskFactoryInterface $ taskFactory ;
2727
2828 /** @var Encoder */
29- private Encoder $ encoder ;
29+ protected Encoder $ encoder ;
3030
3131 /** @var mixed[] */
32- private array $ results = [];
32+ protected array $ results = [];
3333
3434 /** @var int */
35- private int $ sleep ;
35+ protected int $ sleep ;
3636
3737 /**
3838 * Async constructor.
@@ -44,7 +44,7 @@ class Async
4444 public function __construct (
4545 ?TaskFactoryInterface $ taskFactory = null ,
4646 ?Encoder $ encoder = null ,
47- ?int $ sleep = 50
47+ ?int $ sleep = 5000
4848 ) {
4949 $ this ->taskFactory = $ taskFactory ?? new TaskFactory ();
5050 $ this ->encoder = $ encoder ?? new Encoder ();
@@ -53,7 +53,7 @@ public function __construct(
5353 $ this ->listener ();
5454 }
5555
56- private function listener (): void
56+ protected function listener (): void
5757 {
5858 pcntl_async_signals (true );
5959 pcntl_signal (SIGCHLD , function ($ signo , $ status ) {
@@ -79,7 +79,7 @@ private function listener(): void
7979 * @param TaskInterface $task
8080 * @return TaskInterface
8181 */
82- private function finished (TaskInterface $ task ): TaskInterface
82+ protected function finished (TaskInterface $ task ): TaskInterface
8383 {
8484 unset($ this ->progressQueue [$ task ->pid ()]);
8585
@@ -92,7 +92,7 @@ private function finished(TaskInterface $task): TaskInterface
9292 return $ task ;
9393 }
9494
95- private function notify (): void
95+ protected function notify (): void
9696 {
9797 $ process = array_shift ($ this ->pendingQueue );
9898
@@ -107,7 +107,7 @@ private function notify(): void
107107 * @param TaskInterface $task
108108 * @return TaskInterface
109109 */
110- private function progress (TaskInterface $ task ): TaskInterface
110+ protected function progress (TaskInterface $ task ): TaskInterface
111111 {
112112 $ task ->start ();
113113
@@ -122,7 +122,7 @@ private function progress(TaskInterface $task): TaskInterface
122122 * @param TaskInterface $task
123123 * @return TaskInterface
124124 */
125- private function failed (TaskInterface $ task ): TaskInterface
125+ protected function failed (TaskInterface $ task ): TaskInterface
126126 {
127127 unset($ this ->progressQueue [$ task ->pid ()]);
128128
@@ -148,7 +148,7 @@ public function add(callable $process): TaskInterface
148148 * @param TaskInterface $task
149149 * @return TaskInterface
150150 */
151- private function pending (TaskInterface $ task ): TaskInterface
151+ protected function pending (TaskInterface $ task ): TaskInterface
152152 {
153153 $ this ->pendingQueue [$ task ->id ()] = $ task ;
154154
0 commit comments