From 5d88c4a2b80060290467d84033082f3af0c333b2 Mon Sep 17 00:00:00 2001 From: ame Date: Tue, 4 Nov 2025 01:47:09 -0600 Subject: thread testcancel and usleep --- docs/thread/async.md | 21 +++++++++++++++++---- docs/thread/usleep.md | 5 +++++ 2 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 docs/thread/usleep.md (limited to 'docs') diff --git a/docs/thread/async.md b/docs/thread/async.md index 0f04e12..98497ba 100644 --- a/docs/thread/async.md +++ b/docs/thread/async.md @@ -8,6 +8,21 @@ the argument function is executed by the thread until it has been completed. the the reason for the res function it because lua_call (in the c api) requires a number or return values before you run the function +the res function also provides some child methods for thread managment + +### res:testclose + +res:testclose() + +closes the thread if it is being requested to close from async:close + +### res:autoclose + +res:autoclose() + +calls res:testclose() every lua line, using a debug hook + +--- ### async:await @@ -25,12 +40,10 @@ kills the thread, this may close it in an unsafe way, and should be avoided async:close() -kills the thread in a more safe manor, should be preferred in most cases. however it is best to let the thread exit itself - -some systems may not support this (pthread_cancel) and so this function will call async:kill() in cases where it cant. android is one of the main ones +waits for the thread to internally call res:testclose or exit ### async:clean async:clean() -calls the __gc metamethod, will call async:close() if it is still running +calls the __gc metamethod, will call async:kill() if it is still running diff --git a/docs/thread/usleep.md b/docs/thread/usleep.md new file mode 100644 index 0000000..75208a9 --- /dev/null +++ b/docs/thread/usleep.md @@ -0,0 +1,5 @@ +## usleep + +thread.usleep(μN) + +puts the thread to sleep for N microseconds (duh) -- cgit v1.2.3