summaryrefslogtreecommitdiff
path: root/thread_pthread.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-28 00:24:08 (GMT)
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-28 00:24:08 (GMT)
commit4d9c23772ff75b88aa397d913a0477f233d38541 (patch)
tree702448b9753e7345484fd4be4d937f77a15720d6 /thread_pthread.c
parentfcaf874585df8984a23fb89a81bff522cc0ea52e (diff)
thread_pthread.h: rename `gvl.acquired' to `gvl.owner' and document
`acquired' was an old boolean variable, but nowadays it is a rb_thread_t pointer; "gvl.owner" seems like a more appropriate name. And document the contended path including waitq, timer, and timer_err. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index 4f5bc00..f5107bd 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -186,7 +186,7 @@ designate_timer_thread(rb_vm_t *vm)
}
/*
- * We become designated timer thread to kick vm->gvl.acquired
+ * We become designated timer thread to kick vm->gvl.owner
* periodically. Continue on old timeout if it expired.
*/
static void
@@ -220,14 +220,14 @@ do_gvl_timer(rb_vm_t *vm, rb_thread_t *th)
* Timeslice. Warning: the process may fork while this
* thread is contending for GVL:
*/
- if (vm->gvl.acquired) timer_thread_function();
+ if (vm->gvl.owner) timer_thread_function();
vm->gvl.timer = 0;
}
static void
gvl_acquire_common(rb_vm_t *vm, rb_thread_t *th)
{
- if (vm->gvl.acquired) {
+ if (vm->gvl.owner) {
native_thread_data_t *nd = &th->native_thread_data;
VM_ASSERT(th->unblock.func == 0 &&
@@ -242,7 +242,7 @@ gvl_acquire_common(rb_vm_t *vm, rb_thread_t *th)
else {
rb_native_cond_wait(&nd->cond.gvlq, &vm->gvl.lock);
}
- } while (vm->gvl.acquired);
+ } while (vm->gvl.owner);
list_del_init(&nd->node.gvl);
@@ -254,7 +254,7 @@ gvl_acquire_common(rb_vm_t *vm, rb_thread_t *th)
else { /* reset timer if uncontended */
vm->gvl.timer_err = ETIMEDOUT;
}
- vm->gvl.acquired = th;
+ vm->gvl.owner = th;
if (!vm->gvl.timer) {
if (!designate_timer_thread(vm) && !ubf_threads_empty()) {
rb_thread_wakeup_timer_thread(-1);
@@ -274,7 +274,7 @@ static native_thread_data_t *
gvl_release_common(rb_vm_t *vm)
{
native_thread_data_t *next;
- vm->gvl.acquired = 0;
+ vm->gvl.owner = 0;
next = list_top(&vm->gvl.waitq, native_thread_data_t, node.ubf);
if (next) rb_native_cond_signal(&next->cond.gvlq);
@@ -333,7 +333,7 @@ gvl_init(rb_vm_t *vm)
rb_native_cond_initialize(&vm->gvl.switch_cond);
rb_native_cond_initialize(&vm->gvl.switch_wait_cond);
list_head_init(&vm->gvl.waitq);
- vm->gvl.acquired = 0;
+ vm->gvl.owner = 0;
vm->gvl.timer = 0;
vm->gvl.timer_err = ETIMEDOUT;
vm->gvl.need_yield = 0;