Skip to content

Commit

Permalink
update Thread.php
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechsTech committed Mar 11, 2023
1 parent ef40076 commit 5e1a4bc
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions zend/Types/Thread.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class Thread
/** @var \CStruct|CData|CData|\TValue|<> */
private ?\SplQueue $worker = null;

private ?CData $worker_thread = null;
/** @var \pthread_t_ptr */
private ?CData $worker_id = null;

/** @var \MUTEX_T */
private ?CData $worker_mutex = null;
Expand All @@ -30,9 +31,9 @@ final public function get_module(): ?\ThreadsModule
return $this->module;
}

final public function set_thread($tid): void
final public function set_thread(CData $tid): void
{
$this->worker_thread->tid = \ze_cast('pthread_t', $tid);
$this->worker_id = $tid;
}

final public function add(callable $routine, ...$arguments)
Expand All @@ -53,7 +54,6 @@ final public function add(callable $routine, ...$arguments)
if (\ze_ffi()->zend_fcall_info_init($callable(), 0, $fci, $fcc, null, null) === 0) {
$value = new \TValue;
$this->push($worker, $fci, $fcc, $value);
$this->worker_thread = $thread;
return $value;
} else {
\ze_ffi()->zend_error(\E_WARNING, "Failed to add routine!");
Expand Down Expand Up @@ -104,6 +104,7 @@ public function __destruct()

unset($this->worker);
$this->worker = null;
$this->worker_id = null;
\ze_ffi()->tsrm_mutex_free($this->worker_mutex);
$this->worker_mutex = null;
\ffi_free_if($this->server_context);
Expand Down Expand Up @@ -166,7 +167,7 @@ public function empty(): bool

public function join()
{
return \ts_ffi()->pthread_join(\ts_ffi()->cast('pthread_t', $this->worker_thread->tid), NULL);/*
return \ts_ffi()->pthread_join($this->worker_id, NULL);/*
php_parallel_monitor_lock(runtime->monitor);
if (php_parallel_monitor_check(runtime->monitor, PHP_PARALLEL_CLOSED)) {
Expand Down

0 comments on commit 5e1a4bc

Please sign in to comment.