* load.c (load_unlock): release loading barrier and then remove it

from loading_table if it is not in-use.  [Bug #5754]
* thread.c (rb_barrier_release, rb_barrier_destroy): return
  whether any other threads are waiting on it.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2011-12-14 03:20:02 +00:00
Родитель 23f9e74604
Коммит 50c1985555
3 изменённых файлов: 27 добавлений и 8 удалений

Просмотреть файл

@ -1,3 +1,11 @@
Wed Dec 14 12:19:59 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* load.c (load_unlock): release loading barrier and then remove it
from loading_table if it is not in-use. [Bug #5754]
* thread.c (rb_barrier_release, rb_barrier_destroy): return
whether any other threads are waiting on it.
Wed Dec 14 11:23:45 2011 NARUSE, Yui <naruse@ruby-lang.org>
* thread_pthread.c (ubf_select): call rb_thread_wakeup_timer_thread()

10
load.c
Просмотреть файл

@ -427,12 +427,10 @@ load_unlock(const char *ftptr, int done)
if (!st_lookup(loading_tbl, key, &data)) return;
barrier = (VALUE)data;
if (rb_barrier_waiting(barrier) ||
(st_delete(loading_tbl, &key, &data) && (xfree((char *)key), 1))) {
if (done)
rb_barrier_destroy(barrier);
else
rb_barrier_release(barrier);
if (!(done ? rb_barrier_destroy(barrier) : rb_barrier_release(barrier))) {
if (st_delete(loading_tbl, &key, &data)) {
xfree((char *)key);
}
}
}
}

Просмотреть файл

@ -3719,18 +3719,31 @@ rb_barrier_wait(VALUE self)
return waiting ? Qnil : Qfalse;
}
/*
* Release a barrrier, and return true if it has waiting threads.
*/
VALUE
rb_barrier_release(VALUE self)
{
return rb_mutex_unlock(GetBarrierPtr(self));
VALUE mutex = GetBarrierPtr(self);
rb_mutex_t *m;
rb_mutex_unlock(mutex);
GetMutexPtr(mutex, m);
return m->cond_waiting > 0 ? Qtrue : Qfalse;
}
/*
* Release and destroy a barrrier, and return true if it has waiting threads.
*/
VALUE
rb_barrier_destroy(VALUE self)
{
VALUE mutex = GetBarrierPtr(self);
rb_mutex_t *m;
DATA_PTR(self) = 0;
return rb_mutex_unlock(mutex);
rb_mutex_unlock(mutex);
GetMutexPtr(mutex, m);
return m->cond_waiting > 0 ? Qtrue : Qfalse;
}
int