From 5e1a4bc5b474cd26de13ce06bec2900edbbcba75 Mon Sep 17 00:00:00 2001 From: Lawrence Stubbs Date: Sat, 11 Mar 2023 07:26:27 -0500 Subject: [PATCH] update Thread.php --- zend/Types/Thread.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/zend/Types/Thread.php b/zend/Types/Thread.php index ca60f0f..e267aef 100644 --- a/zend/Types/Thread.php +++ b/zend/Types/Thread.php @@ -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; @@ -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) @@ -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!"); @@ -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); @@ -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)) {