Browse Source

some rename

blueloveTH 10 months ago
parent
commit
5b142b21f8
3 changed files with 8 additions and 6 deletions
  1. 4 2
      include/typings/pkpy.pyi
  2. 2 2
      src/modules/pkpy.c
  3. 2 2
      tests/98_thread.py

+ 4 - 2
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): ...

+ 2 - 2
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);
 

+ 2 - 2
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])