mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
some rename
This commit is contained in:
parent
3d6c5c60a3
commit
5b142b21f8
@ -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]): ...
|
def __init__(self, vm_index: Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]): ...
|
||||||
|
|
||||||
@property
|
@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_error(self) -> str | None: ...
|
||||||
def last_retval(self): ...
|
def last_retval(self): ...
|
||||||
|
@ -186,7 +186,7 @@ static bool ComputeThread_is_done(int argc, py_Ref argv) {
|
|||||||
return true;
|
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);
|
PY_CHECK_ARGC(1);
|
||||||
c11_ComputeThread* self = py_touserdata(argv);
|
c11_ComputeThread* self = py_touserdata(argv);
|
||||||
while(!self->is_done)
|
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, __new__, ComputeThread__new__);
|
||||||
py_bindmagic(type, __init__, ComputeThread__init__);
|
py_bindmagic(type, __init__, ComputeThread__init__);
|
||||||
py_bindproperty(type, "is_done", ComputeThread_is_done, NULL);
|
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_error", ComputeThread_last_error);
|
||||||
py_bindmethod(type, "last_retval", ComputeThread_last_retval);
|
py_bindmethod(type, "last_retval", ComputeThread_last_retval);
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@ def func(a):
|
|||||||
return a
|
return a
|
||||||
''')
|
''')
|
||||||
|
|
||||||
thread_1.join()
|
thread_1.wait_for_done()
|
||||||
thread_2.join()
|
thread_2.wait_for_done()
|
||||||
|
|
||||||
thread_1.call('func', [1, 2, 3])
|
thread_1.call('func', [1, 2, 3])
|
||||||
thread_2.call('func', [4, 5, 6])
|
thread_2.call('func', [4, 5, 6])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user