summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-08 04:50:25 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-08 04:50:25 +0000
commit554a33d838a12e92d112d1bba6dac322d4d8160e (patch)
tree2dab1922e45961db57dbcff3174d092146d8d7c1 /thread.c
parent874127452910c0e8ef2f92923b00d0d318520f7f (diff)
* 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
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c48
1 files changed, 19 insertions, 29 deletions
diff --git a/thread.c b/thread.c
index b412dd5fee..34c8ee40db 100644
--- a/thread.c
+++ b/thread.c
@@ -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;