#include "stdinc.h"#include "server.h"Go to the source code of this file.
Functions | |
| Thread * | spawn_thread (void *params, void(*init_fnct)(void *), void(*exit_fnct)(void *)) |
| int | mutex_state (Thread *thread, int lock) |
| Thread * | find_thread () |
| int | dest_thread () |
| void | dest_all_threads (void) |
| int | thread_cancle (Thread *thread) |
| int | thread_wait (Thread *t, pthread_cond_t *cond) |
| int | thread_signal (pthread_cond_t *cond) |
Variables | |
| int | has_dest_threads = 0 |
| pthread_mutex_t | exit_mutex = PTHREAD_MUTEX_INITIALIZER |
| 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 * | thread | ) |
Definition at line 323 of file threads.c.
References alog(), dlink_find_delete(), dlink_free(), LOG_ERROR, thread_count, and threadlist.
| pthread_mutex_t exit_mutex = PTHREAD_MUTEX_INITIALIZER |
Definition at line 37 of file threads.c.
Referenced by dest_thread().
| int has_dest_threads = 0 |
has_dest_threads - Is only true if the core has tried to destroy all threads previously for what ever reason. This prevents from dest_all_threads to be called more then once as it can be possibly fatal.
Definition at line 36 of file threads.c.
Referenced by dest_all_threads().
1.6.3