CSFML - C binding of the Simple and Fast Multimedia Library

CSFML 2.6.1

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

Loading...
Searching...
No Matches
Functions
Thread.h File Reference
`#include <SFML/System/Export.h>`
`#include <SFML/System/Types.h>`

Go to the source code of this file.

## Functions
sfThread * | sfThread_create (void(*function)(void *), void *userData)
| Create a new thread from a function pointer.
void | sfThread_destroy (sfThread *thread)
| Destroy a thread.
void | sfThread_launch (sfThread *thread)
| Run a thread.
void | sfThread_wait (sfThread *thread)
| Wait until a thread finishes.
void | sfThread_terminate (sfThread *thread)
| Terminate a thread.

## Function Documentation

## ◆ sfThread_create()

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.

Parameters

  function | Entry point of the thread
  userData | Custom data to pass to the thread function

Returns
  A new sfThread object

## ◆ sfThread_destroy()

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.

Parameters

  thread | Thread to destroy

## ◆ sfThread_launch()

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.

Parameters

  thread | Thread object

## ◆ sfThread_terminate()

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.

Parameters

  thread | Thread object

## ◆ sfThread_wait()

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.

Parameters

  thread | Thread object