Giter VIP home page Giter VIP logo

php-co-koa's Issues

报错

race 与timeout 里
// helper function
function await($task, ...$args)
{
if ($task instanceof \Generator) {
return $task;
}

if (is_callable($task)) {
    $gen = function() use($task, $args) { yield $task(...$args); };
} else {
    $gen = function() use($task) { yield $task; };
}
return $gen();

}

在这个函数里这么调,await 函数永远也不会得到第二个参数。
有一种情况是,当 执行await时,$task为 Syscall对象时,就执行$gen = function() use($task, $args) { yield $task(...$args); }; 此时 $args为空啊,报错。
PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function Syscall::__invoke(), 0 passed in /home/eric/phpcode/co/Gen.php on line 502 and exactly 1 expected in /home/eric/phpcode/co/Gen.php:158
Stack trace:
#0 /home/eric/phpcode/co/Gen.php(502): Syscall->__invoke()
#1 [internal function]: {closure}()
#2 /home/eric/phpcode/co/Gen.php(24): Generator->current()
#3 /home/eric/phpcode/co/Gen.php(114): Gen->send(NULL)
#4 /home/eric/phpcode/co/Gen.php(98): AsyncTask->next()
#5 /home/eric/phpcode/co/Gen.php(474): AsyncTask->begin(Object(Closure))
#6 /home/eric/phpcode/co/Gen.php(129): Any->begin(Array)
#7 /home/eric/phpcode/co/Gen.php(98): AsyncTask->next()
#8 /home/eric/phpcode/co/Gen.php(320): AsyncTask->begin(Object(Closure))
#9 /home/eric/phpcode/co/Gen.php(578): spawn(Object(Closure))
function race(array $tasks)
{
$tasks = array_map(NAMESPACE . "\await", $tasks);

return new Syscall(function(AsyncTask $parent) use($tasks) {
    if (empty($tasks)) {
        return null;
    } else {
        return new Any($tasks, $parent);
    }
});

}

await 能接受第二个参数吗?

race与timeout 这篇里
// helper function
function await($task, ...$args)
{
if ($task instanceof \Generator) {
return $task;
}

if (is_callable($task)) {
    $gen = function() use($task, $args) { yield $task(...$args); };
} else {
    $gen = function() use($task) { yield $task; };
}
return $gen();

}

await 函数作为array_map的回调函数能接受第二个参数吗?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.