sfThread *sfThread_create(void (*function)(void*), void *userData)#

Create a new thread from a function pointer.

Note: this does not run the thread, use sfThread_launch.

  • function – Entry point of the thread

  • userData – Custom data to pass to the thread function


A new sfThread object

void sfThread_destroy(sfThread *thread)#

Destroy a thread.

This function calls sfThread_wait, so that the internal thread cannot survive after the sfThread object is destroyed.

  • thread – Thread to destroy

void sfThread_launch(sfThread *thread)#

Run a thread.

This function starts the entry point passed to the thread’s constructor, and returns immediately. After this function returns, the thread’s function is running in parallel to the calling code.

  • thread – Thread object

void sfThread_wait(sfThread *thread)#

Wait until a thread finishes.

This function will block the execution until the thread’s function ends. Warning: if the thread function never ends, the calling thread will block forever. If this function is called from its owner thread, it returns without doing anything.

  • thread – Thread object

void sfThread_terminate(sfThread *thread)#

Terminate a thread.

This function immediately stops the thread, without waiting for its function to finish. Terminating a thread with this function is not safe, and can lead to local variables not being destroyed on some operating systems. You should rather try to make the thread function terminate by itself.

  • thread – Thread object