Skip to content

Thread natives

IllidanS4 edited this page Apr 8, 2019 · 3 revisions

thread_fix

native bool:thread_fix();

A thread-safe native that fixes the code to run on the main thread when it is available. If called from another thread, the thread will wait until the following code completes.

thread_detach

native thread_detach(sync_flags:flags);

Detaches the execution of the code from the main thread, executing it in a new thread on the next tick. flags may specify how outer synchronisation happens in the new thread.

thread_attach

native thread_attach();

Attachs the execution back to the main thread.

The two functions above are wrapped in the threaded pseudo-statement which calls them automatically when appropriate.

thread_sync

native thread_sync();

If the thread was created with sync_explicit, callbacks to the code are delayed after the thread ends. Calling this function executes them immediately.

thread_sleep

native thread_sleep(ms);

Pauses the thread for the specified number of milliseconds. Works in the main thread too (will pause the server).

thread_id

native thread_id(id[], size=sizeof id);
native String:thread_id_s();

Returns the identifier of the current thread, usually numeric.

Clone this wiki locally