зеркало из https://github.com/github/ruby.git
* load.c (load_lock): delete the loading barrier if it has been
destroyed. * thread.c (rb_barrier_wait): return nil for recursive lock instead of false, to distinguish it from destroyed barrier. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
aa432d2334
Коммит
f2fff83e96
|
@ -1,3 +1,11 @@
|
|||
Wed Dec 14 10:20:08 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* load.c (load_lock): delete the loading barrier if it has been
|
||||
destroyed.
|
||||
|
||||
* thread.c (rb_barrier_wait): return nil for recursive lock
|
||||
instead of false, to distinguish it from destroyed barrier.
|
||||
|
||||
Wed Dec 14 01:24:55 2011 okkez <okkez000@gmail.com>
|
||||
|
||||
* thread_pthread.c (rb_thread_create_timer_thread): fix memory
|
||||
|
|
10
load.c
10
load.c
|
@ -405,7 +405,15 @@ load_lock(const char *ftptr)
|
|||
rb_warning("loading in progress, circular require considered harmful - %s", ftptr);
|
||||
rb_backtrace();
|
||||
}
|
||||
return RTEST(rb_barrier_wait((VALUE)data)) ? (char *)ftptr : 0;
|
||||
switch (rb_barrier_wait((VALUE)data)) {
|
||||
case Qfalse:
|
||||
data = (st_data_t)ftptr;
|
||||
st_delete(loading_tbl, &data, 0);
|
||||
return 0;
|
||||
case Qnil:
|
||||
return 0;
|
||||
}
|
||||
return (char *)ftptr;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
14
thread.c
14
thread.c
|
@ -3694,19 +3694,29 @@ rb_barrier_new(void)
|
|||
return barrier;
|
||||
}
|
||||
|
||||
/*
|
||||
* Wait a barrier.
|
||||
*
|
||||
* Returns
|
||||
* true: acquired the barrier
|
||||
* false: the barrier was destroyed and no other threads waiting
|
||||
* nil: the barrier was destroyed but still in use
|
||||
*/
|
||||
VALUE
|
||||
rb_barrier_wait(VALUE self)
|
||||
{
|
||||
VALUE mutex = GetBarrierPtr(self);
|
||||
rb_mutex_t *m;
|
||||
int waiting;
|
||||
|
||||
if (!mutex) return Qfalse;
|
||||
GetMutexPtr(mutex, m);
|
||||
if (m->th == GET_THREAD()) return Qfalse;
|
||||
if (m->th == GET_THREAD()) return Qnil;
|
||||
rb_mutex_lock(mutex);
|
||||
if (DATA_PTR(self)) return Qtrue;
|
||||
waiting = m->cond_waiting;
|
||||
rb_mutex_unlock(mutex);
|
||||
return Qfalse;
|
||||
return waiting ? Qnil : Qfalse;
|
||||
}
|
||||
|
||||
VALUE
|
||||
|
|
Загрузка…
Ссылка в новой задаче