Skip to content

Commit

Permalink
Rename Thread::getTsrmInfo to getInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Sep 27, 2024
1 parent 1d24c27 commit 69123f4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ext-src/stubs/php_swoole_thread.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public function detach(): bool {}

public static function getArguments(): ?array {}
public static function getId(): int {}
public static function getTsrmInfo(): array {}
public static function getInfo(): array {}

public static function setName(string $name): bool {}
#ifdef HAVE_CPU_AFFINITY
Expand Down
6 changes: 3 additions & 3 deletions ext-src/stubs/php_swoole_thread_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 5921b76860e0772b4970ee37ebdf397a6054a1e1 */
* Stub hash: d3b07b5e94c81065bab39c16b70384c4572a00dc */

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Swoole_Thread___construct, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, script_file, IS_STRING, 0)
Expand All @@ -19,7 +19,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Swoole_Thread_getId, 0, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Swoole_Thread_getTsrmInfo, 0, 0, IS_ARRAY, 0)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Swoole_Thread_getInfo, 0, 0, IS_ARRAY, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Swoole_Thread_setName, 0, 1, _IS_BOOL, 0)
Expand All @@ -42,7 +42,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Swoole_Thread_setPriority,
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, policy, IS_LONG, 0, "0")
ZEND_END_ARG_INFO()

#define arginfo_class_Swoole_Thread_getPriority arginfo_class_Swoole_Thread_getTsrmInfo
#define arginfo_class_Swoole_Thread_getPriority arginfo_class_Swoole_Thread_getInfo

#if defined(__linux__)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Swoole_Thread_gettid, 0, 0, IS_LONG, 0)
Expand Down
7 changes: 3 additions & 4 deletions ext-src/swoole_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static PHP_METHOD(swoole_thread, joinable);
static PHP_METHOD(swoole_thread, detach);
static PHP_METHOD(swoole_thread, getArguments);
static PHP_METHOD(swoole_thread, getId);
static PHP_METHOD(swoole_thread, getTsrmInfo);
static PHP_METHOD(swoole_thread, getInfo);
static PHP_METHOD(swoole_thread, setName);
#ifdef HAVE_CPU_AFFINITY
static PHP_METHOD(swoole_thread, setAffinity);
Expand All @@ -113,7 +113,7 @@ static const zend_function_entry swoole_thread_methods[] = {
PHP_ME(swoole_thread, detach, arginfo_class_Swoole_Thread_detach, ZEND_ACC_PUBLIC)
PHP_ME(swoole_thread, getArguments, arginfo_class_Swoole_Thread_getArguments, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(swoole_thread, getId, arginfo_class_Swoole_Thread_getId, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(swoole_thread, getTsrmInfo, arginfo_class_Swoole_Thread_getTsrmInfo, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(swoole_thread, getInfo, arginfo_class_Swoole_Thread_getInfo, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(swoole_thread, setName, arginfo_class_Swoole_Thread_setName, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
#ifdef HAVE_CPU_AFFINITY
PHP_ME(swoole_thread, setAffinity, arginfo_class_Swoole_Thread_setAffinity, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
Expand All @@ -124,7 +124,6 @@ static const zend_function_entry swoole_thread_methods[] = {
#ifdef __linux__
PHP_ME(swoole_thread, gettid, arginfo_class_Swoole_Thread_gettid, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
#endif
PHP_MALIAS(swoole_thread, info, getTsrmInfo, arginfo_class_Swoole_Thread_getTsrmInfo, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_FE_END
};
// clang-format on
Expand Down Expand Up @@ -559,7 +558,7 @@ void php_swoole_thread_php_socket_create(zval *return_value, zend_long sockfd) {
}
#endif

static PHP_METHOD(swoole_thread, getTsrmInfo) {
static PHP_METHOD(swoole_thread, getInfo) {
array_init(return_value);
add_assoc_bool(return_value, "is_main_thread", tsrm_is_main_thread());
add_assoc_bool(return_value, "is_shutdown", tsrm_is_shutdown());
Expand Down
4 changes: 2 additions & 2 deletions tests/swoole_thread/info.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Assert::eq(Thread::API_NAME, 'POSIX Threads');

$tm->parentFunc = function () {
$thread = new Thread(__FILE__, 'child');
$info = Thread::getTsrmInfo();
$info = Thread::getInfo();
Assert::true($info['is_main_thread']);
$thread->join();
};

$tm->childFunc = function () {
$info = Thread::getTsrmInfo();
$info = Thread::getInfo();
Assert::false($info['is_main_thread']);
};

Expand Down

0 comments on commit 69123f4

Please sign in to comment.