Thread module

thread_is_done

procedureSource

Whether thread has finished.

Example↗
count := 0;
worker :: (thread: *Thread) -> s64 {
    (cast(*int) thread.data).* = 7;
    return 0;
}

thread: Thread;
assert(thread_init(*thread, worker));
thread.data = *count;
thread_start(*thread);
assert(thread_is_done(*thread, -1)); // wait for it
thread_deinit(*thread);
assert(count == 7);
thread_is_done :: (thread: *Thread, milliseconds: s32 = 0) -> bool

Whether thread has finished.

Parameters

thread: *Thread
milliseconds: s32 = 0
how long to wait for the thread to finish. 0 only checks; -1 waits until it does.

Returns

bool
Example↗
count := 0;
worker :: (thread: *Thread) -> s64 {
    (cast(*int) thread.data).* = 7;
    return 0;
}

thread: Thread;
assert(thread_init(*thread, worker));
thread.data = *count;
thread_start(*thread);
assert(thread_is_done(*thread, -1)); // wait for it
thread_deinit(*thread);
assert(count == 7);

See also