ruby-changes:46953
From: ko1 <ko1@a...>
Date: Mon, 12 Jun 2017 16:49:39 +0900 (JST)
Subject: [ruby-changes:46953] ko1:r59068 (trunk): remove rb_blocking_region_buffer::oldubf.
ko1 2017-06-12 16:49:33 +0900 (Mon, 12 Jun 2017) New Revision: 59068 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59068 Log: remove rb_blocking_region_buffer::oldubf. * thread.c (rb_blocking_region_buffer): remove oldubf because ubf should be NULL just before ubf setting. * thread.c (set_unblock_function, reset_unblock_function): rename to unblock_function_set() and unblock_function_clear() respectively. Modified files: trunk/thread.c Index: thread.c =================================================================== --- thread.c (revision 59067) +++ thread.c (revision 59068) @@ -119,12 +119,10 @@ st_delete_wrap(st_table *table, st_data_ https://github.com/ruby/ruby/blob/trunk/thread.c#L119 struct rb_blocking_region_buffer { enum rb_thread_status prev_status; - struct rb_unblock_callback oldubf; }; -static int set_unblock_function(rb_thread_t *th, rb_unblock_function_t *func, void *arg, - struct rb_unblock_callback *old, int fail_if_interrupted); -static void reset_unblock_function(rb_thread_t *th, const struct rb_unblock_callback *old); +static int unblock_function_set(rb_thread_t *th, rb_unblock_function_t *func, void *arg, int fail_if_interrupted); +static void unblock_function_clear(rb_thread_t *th); static inline int blocking_region_begin(rb_thread_t *th, struct rb_blocking_region_buffer *region, rb_unblock_function_t *ubf, void *arg, int fail_if_interrupted); @@ -378,8 +376,7 @@ rb_nativethread_lock_unlock(rb_nativethr https://github.com/ruby/ruby/blob/trunk/thread.c#L376 } static int -set_unblock_function(rb_thread_t *th, rb_unblock_function_t *func, void *arg, - struct rb_unblock_callback *old, int fail_if_interrupted) +unblock_function_set(rb_thread_t *th, rb_unblock_function_t *func, void *arg, int fail_if_interrupted) { do { if (fail_if_interrupted) { @@ -395,7 +392,8 @@ set_unblock_function(rb_thread_t *th, rb https://github.com/ruby/ruby/blob/trunk/thread.c#L392 } while (RUBY_VM_INTERRUPTED_ANY(th) && (native_mutex_unlock(&th->interrupt_lock), TRUE)); - if (old) *old = th->unblock; + VM_ASSERT(th->unblock.func == NULL); + th->unblock.func = func; th->unblock.arg = arg; native_mutex_unlock(&th->interrupt_lock); @@ -404,10 +402,10 @@ set_unblock_function(rb_thread_t *th, rb https://github.com/ruby/ruby/blob/trunk/thread.c#L402 } static void -reset_unblock_function(rb_thread_t *th, const struct rb_unblock_callback *old) +unblock_function_clear(rb_thread_t *th) { native_mutex_lock(&th->interrupt_lock); - th->unblock = *old; + th->unblock.func = NULL; native_mutex_unlock(&th->interrupt_lock); } @@ -415,11 +413,13 @@ static void https://github.com/ruby/ruby/blob/trunk/thread.c#L413 rb_threadptr_interrupt_common(rb_thread_t *th, int trap) { native_mutex_lock(&th->interrupt_lock); - if (trap) + if (trap) { RUBY_VM_SET_TRAP_INTERRUPT(th); - else + } + else { RUBY_VM_SET_INTERRUPT(th); - if (th->unblock.func) { + } + if (th->unblock.func != NULL) { (th->unblock.func)(th->unblock.arg); } else { @@ -1283,7 +1283,7 @@ blocking_region_begin(rb_thread_t *th, s https://github.com/ruby/ruby/blob/trunk/thread.c#L1283 rb_unblock_function_t *ubf, void *arg, int fail_if_interrupted) { region->prev_status = th->status; - if (set_unblock_function(th, ubf, arg, ®ion->oldubf, fail_if_interrupted)) { + if (unblock_function_set(th, ubf, arg, fail_if_interrupted)) { th->blocking_region_buffer = region; th->status = THREAD_STOPPED; thread_debug("enter blocking region (%p)\n", (void *)th); @@ -1304,7 +1304,7 @@ blocking_region_end(rb_thread_t *th, str https://github.com/ruby/ruby/blob/trunk/thread.c#L1304 thread_debug("leave blocking region (%p)\n", (void *)th); unregister_ubf_list(th); th->blocking_region_buffer = 0; - reset_unblock_function(th, ®ion->oldubf); + unblock_function_clear(th); if (th->status == THREAD_STOPPED) { th->status = region->prev_status; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/