* 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:
parent
23f9e74604
commit
50c1985555
@ -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>
|
Wed Dec 14 11:23:45 2011 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* thread_pthread.c (ubf_select): call rb_thread_wakeup_timer_thread()
|
* thread_pthread.c (ubf_select): call rb_thread_wakeup_timer_thread()
|
||||||
|
10
load.c
10
load.c
@ -427,12 +427,10 @@ load_unlock(const char *ftptr, int done)
|
|||||||
|
|
||||||
if (!st_lookup(loading_tbl, key, &data)) return;
|
if (!st_lookup(loading_tbl, key, &data)) return;
|
||||||
barrier = (VALUE)data;
|
barrier = (VALUE)data;
|
||||||
if (rb_barrier_waiting(barrier) ||
|
if (!(done ? rb_barrier_destroy(barrier) : rb_barrier_release(barrier))) {
|
||||||
(st_delete(loading_tbl, &key, &data) && (xfree((char *)key), 1))) {
|
if (st_delete(loading_tbl, &key, &data)) {
|
||||||
if (done)
|
xfree((char *)key);
|
||||||
rb_barrier_destroy(barrier);
|
}
|
||||||
else
|
|
||||||
rb_barrier_release(barrier);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
17
thread.c
17
thread.c
@ -3719,18 +3719,31 @@ rb_barrier_wait(VALUE self)
|
|||||||
return waiting ? Qnil : Qfalse;
|
return waiting ? Qnil : Qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Release a barrrier, and return true if it has waiting threads.
|
||||||
|
*/
|
||||||
VALUE
|
VALUE
|
||||||
rb_barrier_release(VALUE self)
|
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
|
VALUE
|
||||||
rb_barrier_destroy(VALUE self)
|
rb_barrier_destroy(VALUE self)
|
||||||
{
|
{
|
||||||
VALUE mutex = GetBarrierPtr(self);
|
VALUE mutex = GetBarrierPtr(self);
|
||||||
|
rb_mutex_t *m;
|
||||||
DATA_PTR(self) = 0;
|
DATA_PTR(self) = 0;
|
||||||
return rb_mutex_unlock(mutex);
|
rb_mutex_unlock(mutex);
|
||||||
|
GetMutexPtr(mutex, m);
|
||||||
|
return m->cond_waiting > 0 ? Qtrue : Qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user