Example #1
0
 public function run()
 {
     $return = (yield 'SysCall.KillTask.calling');
     $this->context->set('step1', 'before task killed');
     (yield killTask());
     $this->context->set('step2', 'after task killed');
     (yield 'SysCall.KillTask');
 }
Example #2
0
function task()
{
    $tid = (yield getTaskId());
    $childTid = (yield newTask(childTask()));
    for ($i = 1; $i <= 6; ++$i) {
        echo "Parent task {$tid} iteration {$i}.\n";
        yield;
        if ($i == 3) {
            (yield killTask($childTid));
        }
    }
}
function parentTask()
{
    $tid = (yield getTaskId());
    $childTid = (yield newTask(childTask()));
    for ($i = 1; $i <= 6; $i++) {
        echo "Parent task {$tid} iteration {$i}.<br>";
        yield;
        if ($i == 3) {
            echo "Parent sending message to kill child task.<br>";
            (yield killTask($childTid));
        }
    }
}
Example #4
0
function taskerror()
{
    try {
        (yield killTask(500));
    } catch (Exception $e) {
        echo "try to kill task failed", $e->getMessage(), "\n";
    }
}