aboutsummaryrefslogtreecommitdiffstats
path: root/thread_pthread.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-17 03:27:45 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-17 03:27:45 +0000
commit1261f9ee495dba5a6b856bd515b9d9ba7271df02 (patch)
tree36ecd6439ff648bee4993247abb89cdfe279f644 /thread_pthread.c
parentb833d3a3dde1040690c0808f2b9e65342cce2350 (diff)
downloadruby-1261f9ee495dba5a6b856bd515b9d9ba7271df02.tar.gz
thread_pthread.c: microptimize vm->gvl.waiting checks
"gvl.waiting" is volatile, so the compiler won't perform these optimizations for us. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index 20d0b598cf..78c66a0c63 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -73,8 +73,7 @@ gvl_acquire_common(rb_vm_t *vm)
{
if (vm->gvl.acquired) {
- vm->gvl.waiting++;
- if (vm->gvl.waiting == 1) {
+ if (!vm->gvl.waiting++) {
/*
* Wake up timer thread iff timer thread is slept.
* When timer thread is polling mode, we don't want to
@@ -87,7 +86,7 @@ gvl_acquire_common(rb_vm_t *vm)
rb_native_cond_wait(&vm->gvl.cond, &vm->gvl.lock);
}
- vm->gvl.waiting--;
+ --vm->gvl.waiting;
if (vm->gvl.need_yield) {
vm->gvl.need_yield = 0;