diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | thread.c | 48 |
2 files changed, 25 insertions, 29 deletions
@@ -1,3 +1,9 @@ +Fri Jul 8 13:47:39 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * thread.c (rb_mutex_unlock_all): folded into + rb_threadptr_unlock_all_locking_mutexes. + * thread.c (rb_threadptr_unlock_all_locking_mutexes) ditto. + Fri Jul 8 13:36:02 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com> * thread.c (thread_unlock_all_locking_mutexes): rename to @@ -331,8 +331,25 @@ typedef struct rb_mutex_struct struct rb_mutex_struct *next_mutex; } rb_mutex_t; -static void rb_mutex_unlock_all(rb_mutex_t *mutex, rb_thread_t *th); static void rb_mutex_abandon_all(rb_mutex_t *mutexes); +static const char* rb_mutex_unlock_th(rb_mutex_t *mutex, rb_thread_t volatile *th); + +void +rb_threadptr_unlock_all_locking_mutexes(rb_thread_t *th) +{ + const char *err; + rb_mutex_t *mutex; + rb_mutex_t *mutexes = th->keeping_mutexes; + + while (mutexes) { + mutex = mutexes; + /* rb_warn("mutex #<%p> remains to be locked by terminated thread", + mutexes); */ + mutexes = mutex->next_mutex; + err = rb_mutex_unlock_th(mutex, th); + if (err) rb_bug("invalid keeping_mutexes: %s", err); + } +} void rb_thread_terminate_all(void) @@ -346,9 +363,7 @@ rb_thread_terminate_all(void) } /* unlock all locking mutexes */ - if (th->keeping_mutexes) { - rb_mutex_unlock_all(th->keeping_mutexes, GET_THREAD()); - } + rb_threadptr_unlock_all_locking_mutexes(th); thread_debug("rb_thread_terminate_all (main thread: %p)\n", (void *)th); st_foreach(vm->living_threads, terminate_i, (st_data_t)th); @@ -365,15 +380,6 @@ rb_thread_terminate_all(void) } } -void -rb_threadptr_unlock_all_locking_mutexes(rb_thread_t *th) -{ - if (th->keeping_mutexes) { - rb_mutex_unlock_all(th->keeping_mutexes, th); - th->keeping_mutexes = NULL; - } -} - static void thread_cleanup_func_before_exec(void *th_ptr) { @@ -3607,22 +3613,6 @@ rb_mutex_unlock(VALUE self) } static void -rb_mutex_unlock_all(rb_mutex_t *mutexes, rb_thread_t *th) -{ - const char *err; - rb_mutex_t *mutex; - - while (mutexes) { - mutex = mutexes; - /* rb_warn("mutex #<%p> remains to be locked by terminated thread", - mutexes); */ - mutexes = mutex->next_mutex; - err = rb_mutex_unlock_th(mutex, th); - if (err) rb_bug("invalid keeping_mutexes: %s", err); - } -} - -static void rb_mutex_abandon_all(rb_mutex_t *mutexes) { rb_mutex_t *mutex; |