Threads

An Api to create and manage system threads.

'thread thread_create(f : function:1, p : any) Creates a thread that will be running the function f(p) 'thread thread_current() Returns the current thread void thread_send('thread, msg : any) Send a message into the target thread message queue any thread_read_message(block : bool) Reads a message from the message queue. If block is true, the function only returns when a message is available. If block is false and no message is available in the queue, the function will return immediatly null. 'lock lock_create() Creates a lock which is initially locked void lock_release('lock) Release a lock. The thread does not need to own the lock to be able to release it. If a lock is released several times, it can be acquired as many times bool lock_wait('lock, timeout : number?) Waits for a lock to be released and acquire it. If timeout (in seconds) is not null and expires then the returned value is false 'tls tls_create() Creates thread local storage. This is placeholder that can store a value that will be different depending on the local thread. You must set the tls value to null before exiting the thread or the memory will never be collected. any tls_get('tls) Returns the value set by tls_set for the local thread. void tls_set('tls, any) Set the value of the TLS for the local thread.

©2005 Motion-Twin - Powered by Dokuwiki.