php-async/lib/functions.php

41 lines
579 B
PHP
Raw Normal View History

<?php
2019-01-17 00:49:53 +01:00
use JoopSchilder\Asynchronous\Asynchronous;
use JoopSchilder\Asynchronous\Promise;
2019-01-17 00:49:53 +01:00
if (!function_exists('async')) {
/**
* @param callable $function
* @param mixed ...$parameters
2019-01-17 00:49:53 +01:00
* @return Promise
*/
function async(callable $function, ...$parameters)
{
return Asynchronous::run($function, ...$parameters);
}
}
if (!function_exists('async_cleanup')) {
2019-01-17 00:49:53 +01:00
/**
*
*/
function async_cleanup()
{
Asynchronous::cleanup();
}
}
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
}
}