A Scripting Language for Web, Linux and Windows

A Scripting Language for Web, Linux and Windows

Thread functions

The following thread functions are supported.

Function/Arguments Return Description
thread_create (string function, [mixed arg1...]) handle Create a new thread which will be run on function. Optional function arguments can be set. On success the new thread handle is returned, otherwise null is returned. Note! To start the thread you have to call thread_start().
thread_start (handle thread, bool waitRunning=true) bool Start the thread which was created with thread_create(). If waitRunning is true thread_start() waits until the thread function is running. If waitRunning is false thread_start() return immediately, this could cause problems with variable initialization if the parent thread will be finished before the child thread begins to run. Otherwise you can create faster children threads if you keep care that the parent thread will be alive. On success true is returned.
thread_join (handle thread, number milliseconds=0) bool Join the thread a specific time in milliseconds. If milliseconds=0 the thread is joined infinite until it was finished. If the thread was finished then true is returned.
thread_wait (number milliseconds=0) bool thread_wait() must be called within the thread function and waits for a thread_signal(). If milliseconds=0 the thread waits infinite time. If thread_signal() was received then true is returned.
thread_signal (handle thread) bool Send the waiting thread a signal to weak up from thread_wait() function. On success true is returned.
thread_kill (handle thread) bool Kill a active thread immediately. On succes true is returned.
thread_close (handle thread) bool Close the thread handle. If thread is still active it will be killed before. On success true is returned.
thread_is_active (handle thread) bool Return true if the thread is active (running).
thread_set_finish (handle thread) bool Tell the thread that it should finish. thread_set_finish() only set a flag which can be checked with thead_is_finish(). If thread is waiting you have to weak up the thread with thread_signal(). On success true is returned.
thread_is_finish () bool Return true if the current running thread should finish. See thread_set_finish()
thread_suspend (handle thread) bool Suspend the thread. On success true is returned.
thread_resume (handle thread) bool Resume the thread. On success true is returned.
thread_sync_enter () bool Enter a synchronized program part. All instructions between thread_sync_enter() and thread_sync_leave() are exclusive executed and not involved by any other thread which will wait until thread_sync_leave() was called. On success true is returned.
thread_sync_leave () bool Leave a synchronized program part. On success true is returned.
sleep (number milliseconds) true Sleep some milliseconds.

back to Home

V1 Version 0.96 - Documentation generated Sun, 05 May 2024 07:59