summaryrefslogtreecommitdiff
path: root/thread_sync.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-03-14 20:17:32 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-03-14 20:18:30 +0900
commit8a5a91eead7c026ea71dca3063345451d16c948b (patch)
tree5054a126c4965dc668f8c9b22647de5fb6f069bf /thread_sync.c
parentce9fb9b23cc95207a09410ecfdaeecf27e5457f0 (diff)
downloadruby-8a5a91eead7c026ea71dca3063345451d16c948b.tar.gz
--dont-cuddle-else [ci skip]
Diffstat (limited to 'thread_sync.c')
-rw-r--r--thread_sync.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/thread_sync.c b/thread_sync.c
index 94e6340b16..98549b1605 100644
--- a/thread_sync.c
+++ b/thread_sync.c
@@ -34,7 +34,8 @@ sync_wakeup(struct list_head *head, long max)
if (cur->th->scheduler != Qnil && rb_fiberptr_blocking(cur->fiber) == 0) {
rb_fiber_scheduler_unblock(cur->th->scheduler, cur->self, rb_fiberptr_self(cur->fiber));
- } else {
+ }
+ else {
rb_threadptr_interrupt(cur->th);
cur->th->status = THREAD_RUNNABLE;
}
@@ -316,7 +317,8 @@ do_mutex_lock(VALUE self, int interruptible_p)
if (!mutex->fiber) {
mutex->fiber = fiber;
}
- } else {
+ }
+ else {
enum rb_thread_status prev_status = th->status;
rb_hrtime_t *timeout = 0;
rb_hrtime_t rel = rb_msec2hrtime(100);
@@ -440,7 +442,8 @@ rb_mutex_unlock_th(rb_mutex_t *mutex, rb_thread_t *th, rb_fiber_t *fiber)
if (cur->th->scheduler != Qnil && rb_fiberptr_blocking(cur->fiber) == 0) {
rb_fiber_scheduler_unblock(cur->th->scheduler, cur->self, rb_fiberptr_self(cur->fiber));
goto found;
- } else {
+ }
+ else {
switch (cur->th->status) {
case THREAD_RUNNABLE: /* from someone else calling Thread#run */
case THREAD_STOPPED_FOREVER: /* likely (rb_mutex_lock) */
@@ -549,10 +552,12 @@ rb_mutex_sleep(VALUE self, VALUE timeout)
if (scheduler != Qnil) {
rb_fiber_scheduler_kernel_sleep(scheduler, timeout);
mutex_lock_uninterruptible(self);
- } else {
+ }
+ else {
if (NIL_P(timeout)) {
rb_ensure(rb_mutex_sleep_forever, self, mutex_lock_uninterruptible, self);
- } else {
+ }
+ else {
rb_hrtime_t rel = rb_timeval2hrtime(&t);
rb_ensure(rb_mutex_wait_for, (VALUE)&rel, mutex_lock_uninterruptible, self);
}