From 5b142b21f8eaf4876cf3ce137903acd25c6e5c3d Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sun, 13 Apr 2025 19:19:45 +0800 Subject: [PATCH] some rename --- include/typings/pkpy.pyi | 6 ++++-- src/modules/pkpy.c | 4 ++-- tests/98_thread.py | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/typings/pkpy.pyi b/include/typings/pkpy.pyi index 1c3de4ea..ed5205e3 100644 --- a/include/typings/pkpy.pyi +++ b/include/typings/pkpy.pyi @@ -26,9 +26,11 @@ class ComputeThread: def __init__(self, vm_index: Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]): ... @property - def is_done(self) -> bool: ... + def is_done(self) -> bool: + """Check if the current job is done.""" - def join(self) -> None: ... + def wait_for_done(self) -> None: + """Wait for the current job to finish.""" def last_error(self) -> str | None: ... def last_retval(self): ... diff --git a/src/modules/pkpy.c b/src/modules/pkpy.c index 74dea82d..21aa8c58 100644 --- a/src/modules/pkpy.c +++ b/src/modules/pkpy.c @@ -186,7 +186,7 @@ static bool ComputeThread_is_done(int argc, py_Ref argv) { return true; } -static bool ComputeThread_join(int argc, py_Ref argv) { +static bool ComputeThread_wait_for_done(int argc, py_Ref argv) { PY_CHECK_ARGC(1); c11_ComputeThread* self = py_touserdata(argv); while(!self->is_done) @@ -360,7 +360,7 @@ static void pk_ComputeThread__register(py_Ref mod) { py_bindmagic(type, __new__, ComputeThread__new__); py_bindmagic(type, __init__, ComputeThread__init__); py_bindproperty(type, "is_done", ComputeThread_is_done, NULL); - py_bindmethod(type, "join", ComputeThread_join); + py_bindmethod(type, "wait_for_done", ComputeThread_wait_for_done); py_bindmethod(type, "last_error", ComputeThread_last_error); py_bindmethod(type, "last_retval", ComputeThread_last_retval); diff --git a/tests/98_thread.py b/tests/98_thread.py index 1a9883b3..07b1c382 100644 --- a/tests/98_thread.py +++ b/tests/98_thread.py @@ -15,8 +15,8 @@ def func(a): return a ''') -thread_1.join() -thread_2.join() +thread_1.wait_for_done() +thread_2.wait_for_done() thread_1.call('func', [1, 2, 3]) thread_2.call('func', [4, 5, 6])