1/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2/* If you are missing that file, acquire a complete release at teeworlds.com. */
3
4#ifndef BASE_THREAD_H
5#define BASE_THREAD_H
6
7/**
8 * Threading related functions.
9 *
10 * @defgroup Threads Threading
11 *
12 * @see Locks
13 * @see Semaphore
14 */
15
16/**
17 * Creates a new thread.
18 *
19 * @ingroup Threads
20 *
21 * @param threadfunc Entry point for the new thread.
22 * @param user Pointer to pass to the thread.
23 * @param name Name describing the use of the thread.
24 *
25 * @return Handle for the new thread.
26 */
27void *thread_init(void (*threadfunc)(void *), void *user, const char *name);
28
29/**
30 * Waits for a thread to be done or destroyed.
31 *
32 * @ingroup Threads
33 *
34 * @param thread Thread to wait for.
35 */
36void thread_wait(void *thread);
37
38/**
39 * Yield the current thread's execution slice.
40 *
41 * @ingroup Threads
42 */
43void thread_yield();
44
45/**
46 * Puts the thread in the detached state, guaranteeing that
47 * resources of the thread will be freed immediately when the
48 * thread terminates.
49 *
50 * @ingroup Threads
51 *
52 * @param thread Thread to detach.
53 */
54void thread_detach(void *thread);
55
56/**
57 * Creates a new thread and detaches it.
58 *
59 * @ingroup Threads
60 *
61 * @param threadfunc Entry point for the new thread.
62 * @param user Pointer to pass to the thread.
63 * @param name Name describing the use of the thread.
64 */
65void thread_init_and_detach(void (*threadfunc)(void *), void *user, const char *name);
66
67#endif
68