File tree 4 files changed +27
-1
lines changed
4 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 17
17
"skrtdev\\ async\\ " : " src/"
18
18
},
19
19
"files" :[
20
- " src/range.php"
20
+ " src/range.php" ,
21
+ " src/helpers.php"
21
22
]
22
23
}
23
24
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+ require '../vendor/autoload.php ' ;
3
+
4
+ async (function (){
5
+ sleep (3 );
6
+ echo 'Wow, this seems to be async ' , PHP_EOL ;
7
+ });
8
+
9
+ echo 'Hello world ' , PHP_EOL ;
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ class Pool{
16
16
private bool $ is_resolving_queue = false ;
17
17
private bool $ need_tick = true ;
18
18
19
+ protected static self $ default_pool ;
20
+
19
21
public function __construct (?int $ max_childs = null , bool $ kill_childs = true )
20
22
{
21
23
if (!extension_loaded ('pcntl ' )){
@@ -254,6 +256,11 @@ public static function isProcessRunning(int $pid): bool
254
256
return posix_getpgid ($ pid ) !== false ;
255
257
}
256
258
259
+ public static function getDefaultPool (): self
260
+ {
261
+ return static ::$ default_pool ??= new static ();
262
+ }
263
+
257
264
}
258
265
259
266
Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types=1 );
2
+
3
+ use skrtdev \async \Pool ;
4
+
5
+ if (!function_exists ('async ' )){
6
+ function async (callable $ callable , ...$ args ){
7
+ Pool::getDefaultPool ()->parallel ($ callable , ...$ args );
8
+ }
9
+ }
You can’t perform that action at this time.
0 commit comments