From: Sebastian B. <sb...@us...> - 2013-12-13 21:04:14
|
Update of /cvsroot/simplemail/simplemail/gtk In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv21699 Modified Files: subthreads.c Log Message: First basic implementation of thread_add() Index: subthreads.c =================================================================== RCS file: /cvsroot/simplemail/simplemail/gtk/subthreads.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- subthreads.c 13 Dec 2013 18:52:05 -0000 1.11 +++ subthreads.c 13 Dec 2013 21:04:12 -0000 1.12 @@ -111,18 +111,23 @@ } } +/***************************************************************************************/ -/************************************************************************** - Runs a given function in a newly created thread under the given name which - in linked into a internal list. -**************************************************************************/ thread_t thread_add(char *thread_name, int (*entry)(void *), void *eudata) { - fprintf(stderr, "%s not implemented yet!\n", __PRETTY_FUNCTION__); - exit(1); + GThread *t; + if ((t = g_thread_create((GThreadFunc)entry,eudata,TRUE,NULL))) + { + g_mutex_lock(thread_mutex); + g_cond_wait(thread_cond,thread_mutex); + g_mutex_unlock(thread_mutex); + return (thread_t)t; + } return NULL; } +/***************************************************************************************/ + int thread_start(int (*entry)(void*), void *udata) { if (!input_added) @@ -141,12 +146,16 @@ return 0; } +/***************************************************************************************/ + void thread_abort(thread_t thread) { fprintf(stderr, "%s not implemented yet!\n", __PRETTY_FUNCTION__); exit(1); } +/***************************************************************************************/ + /* Call the function synchron, calls timer_callback on the calling process context */ int thread_call_parent_function_sync_timer_callback(void (*timer_callback)(void*), void *timer_data, int millis, void *function, int argcount, ...) { |