@@ -79,7 +79,7 @@ static void thread_join(zend_object *object) {
7979 ThreadObject *to = thread_fetch_object (object);
8080 if (to->thread && to->thread ->joinable ()) {
8181 to->thread ->join ();
82- php_swoole_thread_join (to->thread_id );
82+ php_swoole_thread_join (to->thread -> native_handle () );
8383 delete to->thread ;
8484 to->thread = nullptr ;
8585 }
@@ -110,6 +110,8 @@ static PHP_METHOD(swoole_thread, detach);
110110static PHP_METHOD (swoole_thread, getArguments);
111111static PHP_METHOD (swoole_thread, getId);
112112static PHP_METHOD (swoole_thread, getInfo);
113+ static PHP_METHOD (swoole_thread, activeCount);
114+ static PHP_METHOD (swoole_thread, yield);
113115static PHP_METHOD (swoole_thread, setName);
114116#ifdef HAVE_CPU_AFFINITY
115117static PHP_METHOD (swoole_thread, setAffinity);
@@ -131,6 +133,8 @@ static const zend_function_entry swoole_thread_methods[] = {
131133 PHP_ME (swoole_thread, getArguments, arginfo_class_Swoole_Thread_getArguments, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
132134 PHP_ME (swoole_thread, getId, arginfo_class_Swoole_Thread_getId, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
133135 PHP_ME (swoole_thread, getInfo, arginfo_class_Swoole_Thread_getInfo, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
136+ PHP_ME (swoole_thread, activeCount, arginfo_class_Swoole_Thread_activeCount, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
137+ PHP_ME (swoole_thread, yield, arginfo_class_Swoole_Thread_yield, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
134138 PHP_ME (swoole_thread, setName, arginfo_class_Swoole_Thread_setName, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
135139#ifdef HAVE_CPU_AFFINITY
136140 PHP_ME (swoole_thread, setAffinity, arginfo_class_Swoole_Thread_setAffinity, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
@@ -580,6 +584,14 @@ static PHP_METHOD(swoole_thread, getInfo) {
580584 add_assoc_long (return_value, " thread_num" , thread_num.load ());
581585}
582586
587+ static PHP_METHOD (swoole_thread, activeCount) {
588+ RETURN_LONG (thread_num.load ());
589+ }
590+
591+ static PHP_METHOD (swoole_thread, yield) {
592+ std::this_thread::yield ();
593+ }
594+
583595#define CAST_OBJ_TO_RESOURCE (_name, _type ) \
584596 else if (instanceof_function(Z_OBJCE_P(zvalue), swoole_thread_##_name##_ce)) { \
585597 value.resource = php_swoole_thread_##_name##_cast (zvalue); \
0 commit comments