* 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:
parent
8741274529
commit
554a33d838
@ -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>
|
Fri Jul 8 13:36:02 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
* thread.c (thread_unlock_all_locking_mutexes): rename to
|
* thread.c (thread_unlock_all_locking_mutexes): rename to
|
||||||
|
48
thread.c
48
thread.c
@ -331,8 +331,25 @@ typedef struct rb_mutex_struct
|
|||||||
struct rb_mutex_struct *next_mutex;
|
struct rb_mutex_struct *next_mutex;
|
||||||
} rb_mutex_t;
|
} 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 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
|
void
|
||||||
rb_thread_terminate_all(void)
|
rb_thread_terminate_all(void)
|
||||||
@ -346,9 +363,7 @@ rb_thread_terminate_all(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* unlock all locking mutexes */
|
/* unlock all locking mutexes */
|
||||||
if (th->keeping_mutexes) {
|
rb_threadptr_unlock_all_locking_mutexes(th);
|
||||||
rb_mutex_unlock_all(th->keeping_mutexes, GET_THREAD());
|
|
||||||
}
|
|
||||||
|
|
||||||
thread_debug("rb_thread_terminate_all (main thread: %p)\n", (void *)th);
|
thread_debug("rb_thread_terminate_all (main thread: %p)\n", (void *)th);
|
||||||
st_foreach(vm->living_threads, terminate_i, (st_data_t)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
|
static void
|
||||||
thread_cleanup_func_before_exec(void *th_ptr)
|
thread_cleanup_func_before_exec(void *th_ptr)
|
||||||
{
|
{
|
||||||
@ -3606,22 +3612,6 @@ rb_mutex_unlock(VALUE self)
|
|||||||
return 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
|
static void
|
||||||
rb_mutex_abandon_all(rb_mutex_t *mutexes)
|
rb_mutex_abandon_all(rb_mutex_t *mutexes)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user