1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* thread.c (rb_mutex_unlock_all): folded into

rb_threadptr_unlock_all_locking_mutexes.
* thread.c (rb_threadptr_unlock_all_locking_mutexes) ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kosaki 2011-07-08 04:50:25 +00:00
parent 8741274529
commit 554a33d838
2 changed files with 25 additions and 29 deletions

View file

@ -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

View file

@ -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)
{
@ -3606,22 +3612,6 @@ rb_mutex_unlock(VALUE self)
return 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)
{