2019-01-16 16:22:02 +01:00
|
|
|
<?php
|
2019-01-17 00:49:53 +01:00
|
|
|
use JoopSchilder\Asynchronous\Asynchronous;
|
|
|
|
use JoopSchilder\Asynchronous\Promise;
|
2019-01-16 16:22:02 +01:00
|
|
|
|
2019-01-17 00:49:53 +01:00
|
|
|
if (!function_exists('async')) {
|
2019-01-16 16:22:02 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param callable $function
|
|
|
|
* @param mixed ...$parameters
|
2019-01-17 00:49:53 +01:00
|
|
|
* @return Promise
|
2019-01-16 16:22:02 +01:00
|
|
|
*/
|
|
|
|
function async(callable $function, ...$parameters)
|
|
|
|
{
|
|
|
|
return Asynchronous::run($function, ...$parameters);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-08 01:10:25 +01:00
|
|
|
if (!function_exists('async_cleanup')) {
|
2019-01-17 00:49:53 +01:00
|
|
|
|
2019-01-16 16:22:02 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2019-12-08 01:10:25 +01:00
|
|
|
function async_cleanup()
|
2019-01-16 16:22:02 +01:00
|
|
|
{
|
2019-12-08 01:10:25 +01:00
|
|
|
Asynchronous::cleanup();
|
2019-01-16 16:22:02 +01:00
|
|
|
}
|
|
|
|
}
|
2019-01-16 16:53:44 +01:00
|
|
|
|
|
|
|
|
2019-01-17 00:49:53 +01:00
|
|
|
if (!function_exists('async_wait_all')) {
|
|
|
|
|
2019-01-16 16:53:44 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2019-01-17 00:49:53 +01:00
|
|
|
function async_wait_all()
|
2019-01-16 16:53:44 +01:00
|
|
|
{
|
2019-01-17 00:49:53 +01:00
|
|
|
Asynchronous::waitForChildren();
|
2019-01-16 16:53:44 +01:00
|
|
|
}
|
2019-12-08 01:10:25 +01:00
|
|
|
}
|