diff options
author | Samuel Williams <[email protected]> | 2020-05-14 22:10:55 +1200 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-14 22:10:55 +1200 |
commit | 0e3b0fcdba70cf96a8e0654eb8f50aacb8024bd4 (patch) | |
tree | 74d381412dfd8ff49dd3039f8aeae09ad9e4e6e3 /thread_sync.c | |
parent | 336119dfc5e6baae0a936d6feae780a61975479c (diff) |
Thread scheduler for light weight concurrency.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3032
Merged-By: ioquatix <[email protected]>
Diffstat (limited to 'thread_sync.c')
-rw-r--r-- | thread_sync.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/thread_sync.c b/thread_sync.c index 2e20812f4d..3689dee789 100644 --- a/thread_sync.c +++ b/thread_sync.c @@ -190,6 +190,8 @@ mutex_locked(rb_thread_t *th, VALUE self) mutex->next_mutex = th->keeping_mutexes; } th->keeping_mutexes = mutex; + + th->blocking += 1; } /* @@ -365,6 +367,8 @@ rb_mutex_unlock_th(rb_mutex_t *mutex, rb_thread_t *th) struct sync_waiter *cur = 0, *next; rb_mutex_t **th_mutex = &th->keeping_mutexes; + th->blocking -= 1; + mutex->th = 0; list_for_each_safe(&mutex->waitq, cur, next, node) { list_del_init(&cur->node); @@ -404,8 +408,9 @@ rb_mutex_unlock(VALUE self) { const char *err; rb_mutex_t *mutex = mutex_ptr(self); + rb_thread_t *th = GET_THREAD(); - err = rb_mutex_unlock_th(mutex, GET_THREAD()); + err = rb_mutex_unlock_th(mutex, th); if (err) rb_raise(rb_eThreadError, "%s", err); return self; |