From: Sebastian B. <sb...@us...> - 2013-12-24 09:26:10
|
Update of /cvsroot/simplemail/simplemail/gtk In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv420/gtk Modified Files: subthreads.c Log Message: Implemented thread_aborted(). Index: subthreads.c =================================================================== RCS file: /cvsroot/simplemail/simplemail/gtk/subthreads.c,v retrieving revision 1.53 retrieving revision 1.54 diff -u -d -r1.53 -r1.54 --- subthreads.c 24 Dec 2013 09:25:47 -0000 1.53 +++ subthreads.c 24 Dec 2013 09:26:08 -0000 1.54 @@ -55,9 +55,11 @@ { struct node node; GThread *thread; - GMainContext *context; GMainLoop *main_loop; + + GMutex *mutex; + int aborted; }; static struct thread_s main_thread; @@ -80,6 +82,8 @@ return 0; if (!(main_thread.main_loop = g_main_loop_new(main_thread.context, FALSE))) return 0; + if (!(main_thread.mutex = g_mutex_new())) + return 0; return 1; } @@ -110,6 +114,7 @@ } } + g_mutex_free(main_thread.mutex); g_main_loop_unref(main_thread.main_loop); g_main_context_unref(main_thread.context); @@ -154,6 +159,7 @@ t->thread = g_thread_self(); t->context = g_main_context_new(); t->main_loop = g_main_loop_new(t->context, FALSE); + t->mutex = g_mutex_new(); tad->entry(tad->eudata); @@ -161,6 +167,7 @@ node_remove(&t->node); g_mutex_unlock(thread_list_mutex); + g_mutex_free(t->mutex); g_main_loop_unref(t->main_loop); g_main_context_unref(t->context); return NULL; @@ -222,6 +229,9 @@ void thread_abort(thread_t thread) { + g_mutex_lock(thread->mutex); + thread->aborted = 1; + g_mutex_unlock(thread->mutex); g_main_context_invoke(thread->context, thread_abort_entry, thread); } @@ -616,7 +626,12 @@ int thread_aborted(void) { - return 0; + struct thread_s *t = thread_get(); + int aborted; + g_mutex_lock(t->mutex); + aborted = !!t->aborted; + g_mutex_unlock(t->mutex); + return aborted; } /***************************************************************************************/ |