Go to the source code of this file.
Data Structures | |
| struct | Thread |
Defines | |
| #define | NUM_THREADS 100 |
| #define | THREAD_OK 0 |
| #define | THREAD_MUTEX_LOCK 1 |
| #define | THREAD_MUTEX_UNLOCK 2 |
Functions | |
| Thread * | spawn_thread (void *params, void(*init_fnct)(void *), void(*exit_fnct)(void *)) |
| Thread * | find_thread () |
| int | dest_thread () |
| int | mutex_state (Thread *, int) |
| void | dest_all_threads (void) |
| int | thread_wait (Thread *, pthread_cond_t *) |
| int | thread_signal (pthread_cond_t *) |
| int | thread_cancle (Thread *) |
Variables | |
| dlink_list | threadlist |
| int | thread_count |
| #define THREAD_MUTEX_LOCK 1 |
Definition at line 10 of file threads.h.
Referenced by mutex_state().
| #define THREAD_MUTEX_UNLOCK 2 |
Definition at line 11 of file threads.h.
Referenced by mutex_state().
| void dest_all_threads | ( | void | ) |
dest_all_threads - This destroys all threads within the thread list, and removes their entries from the list.
Definition at line 267 of file threads.c.
References alog(), dlink_find_delete(), DLINK_FOREACH_SAFE, dlink_free(), has_dest_threads, LOG_ERROR, thread_count, and threadlist.
Referenced by AtExit().
| int dest_thread | ( | ) |
dest_thread - Destroy calling thread and remove it from threadlist all threads are required to call this function before exiting as it insures cleanup and prevents stale thread entires.
Definition at line 207 of file threads.c.
References dlink_find_delete(), DLINK_FOREACH_SAFE, dlink_free(), exit_mutex, thread_count, and threadlist.
| Thread* find_thread | ( | ) |
find_thread - Find a thread by corresponding TID note only threads can call this function as it uses pthread_self to determin the thread we are looking for.
Definition at line 178 of file threads.c.
References DLINK_FOREACH_SAFE, and threadlist.
| int mutex_state | ( | Thread * | thread, | |
| int | lock | |||
| ) |
mutex_state - This function locks the thread mutex found in Thread::mutex it also prevents deadlock from occuring within the threading by implementing pthread_trylock().
| thread | - A pointer to the thread structure holding our threads data. | |
| lock | - weather or not we are to lock our mutex or unlock it |
Definition at line 140 of file threads.c.
References s_assert, THREAD_MUTEX_LOCK, and THREAD_MUTEX_UNLOCK.
| Thread* spawn_thread | ( | void * | params, | |
| void(*)(void *) | init_fnct, | |||
| void(*)(void *) | exit_fnct | |||
| ) |
spawn_thread - spawns a thread and sets it to the detatched state. This thread I accessable by accessing the structure which is returned upon a successfull call. these threads are globally useable and do not have any predefined behavior, besides being detatched on creation.
| params | The arguments to be passed to both init_fnct and exit_fnct | |
| init_fnct | A function pointer to the entry point of the spawning thread threads jump into this at the begining of normal execution. | |
| exit_fnct | This is a pointer to the cleanup function, which is called before a thread destroyes. |
Definition at line 59 of file threads.c.
References alog(), dlink_add_tail(), dlink_create(), LOG_ERROR, thread_count, and threadlist.
| int thread_cancle | ( | Thread * | ) |
Definition at line 323 of file threads.c.
References alog(), dlink_find_delete(), dlink_free(), LOG_ERROR, thread_count, and threadlist.
| int thread_count |
Definition at line 51 of file threads.h.
Referenced by dest_all_threads(), dest_thread(), spawn_thread(), and thread_cancle().
| dlink_list threadlist |
Definition at line 38 of file threads.h.
Referenced by dest_all_threads(), dest_thread(), find_thread(), spawn_thread(), and thread_cancle().
1.6.3