Skip to content

Commit

Permalink
update/staging add dependency for Threading, buggy
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechsTech committed Mar 7, 2023
1 parent ba3464a commit 372ff3c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -10,3 +10,4 @@ vendor/
*.csr
*.local
temp
test.php
5 changes: 3 additions & 2 deletions Coroutine/Coroutine.php
Expand Up @@ -4,11 +4,12 @@

namespace Async;

use Async\Spawn\Thread;
use Async\Spawn\Future;
use Async\Spawn\FutureHandler;
use Async\Spawn\FutureInterface;
use Async\Spawn\ChanneledInterface;
use Async\Threads\Thread;
use Async\Threads\TWorker;
use Async\Kernel;
use Async\Task;
use Async\Parallel;
Expand Down Expand Up @@ -488,7 +489,7 @@ public function addFuture($callable, int $timeout = 0, bool $display = false, $c
return $display ? $future->displayOn() : $future;
}

public function addThread(int $tid, callable $callable, ...$args): Thread
public function addThread(int $tid, callable $callable, ...$args): TWorker
{
return $this->thread->create($tid, $callable, ...$args);
}
Expand Down
7 changes: 4 additions & 3 deletions Coroutine/CoroutineInterface.php
Expand Up @@ -8,7 +8,8 @@
use Async\Spawn\Channeled;
use Async\Spawn\FutureInterface;
use Async\RuntimeException;
use Async\Spawn\Thread;
use Async\Threads\Thread;
use Async\Threads\TWorker;

interface CoroutineInterface
{
Expand Down Expand Up @@ -304,9 +305,9 @@ public function addFuture($callable, int $timeout = 0, bool $display = false, $c
* @param string|int $tid Thread ID
* @param callable $callable
* @param mixed ...$args
* @return Thread
* @return TWorker
*/
public function addThread(int $tid, callable $callable, ...$args): Thread;
public function addThread(int $tid, callable $callable, ...$args): TWorker;

/**
* There are no **UV** file system operations/events pending.
Expand Down
9 changes: 5 additions & 4 deletions Coroutine/Kernel.php
Expand Up @@ -21,7 +21,8 @@
use Async\Misc\ContextInterface;
use Async\Misc\Semaphore;
use Async\Misc\TimeoutAfter;
use Async\Spawn\Thread;
use Async\Threads\Thread;
use Async\Threads\TWorker;
use Async\Spawn\Channeled;
use Async\Spawn\FutureInterface;
use Psr\Container\ContainerInterface;
Expand Down Expand Up @@ -275,7 +276,7 @@ function (TaskInterface $task, CoroutineInterface $coroutine) use ($tid, $custom

$error = ($isContext || $type) ? new TaskCancelled("Task {$tid}!") : new CancelledError("Task {$tid}!");
$customData = $cancelTask->getCustomData();
if ($customData instanceof FutureInterface || $customData instanceof Thread) {
if ($customData instanceof FutureInterface || $customData instanceof Thread || $customData instanceof TWorker) {
$task->sendValue(true);
$cancelTask->setCaller($task);
if ($customData instanceof FutureInterface) {
Expand Down Expand Up @@ -334,7 +335,7 @@ function (TaskInterface $task, CoroutineInterface $coroutine) use ($tid) {
}

$customData = $join->getCustomData();
if ($customData instanceof Thread) {
if ($customData instanceof Thread || $customData instanceof TWorker) {
$coroutine->schedule($join);
return $customData->join($tid);
}
Expand Down Expand Up @@ -1168,7 +1169,7 @@ function (TaskInterface $task, CoroutineInterface $coroutine) use ($callable, $t
$callableTask = $coroutine->getTask($taskId);
if (!$coroutine->isCompleted($taskId)) {
$futureThread = $callableTask->getCustomData();
if ($futureThread instanceof FutureInterface || $futureThread instanceof Thread) {
if ($futureThread instanceof FutureInterface || $futureThread instanceof Thread || $futureThread instanceof TWorker) {
$callableTask->setCaller($task);
if ($futureThread instanceof FutureInterface) {
$delay = 1;
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -41,7 +41,8 @@
"php": ">7.1",
"psr/log": "^1.0.0",
"psr/container": ">2.0",
"symplely/spawn": "^4.1.8"
"symplely/spawn": "^5",
"symplely/thread_queue": "main-dev"
},
"autoload": {
"files": [
Expand Down

0 comments on commit 372ff3c

Please sign in to comment.