rb_thread_schedule().
And also rename to rb_thead_schedule_limits() and remove
sched_depth argument. It's no longer called recursive.
* thread.c (rb_thread_schedule): add to check interrupt_flag as
above explained.
* thread.c (rb_threadptr_execute_interrupts_rec): rename to
rb_threadptr_execute_interrupts_common() and remove sched_depth
argument. It's no longer called recursive.
* thread.c (rb_thread_sleep): adapt the renaming.
* thread.c (rb_threadptr_execute_interrupts): ditto.
* thread.c (rb_thread_execute_interrupts): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
a sample code. The actual implementaion never behave as explained by
an example. It's a documentation bug.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32301 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
example is buggy and may cause deadlock. The patch is
suggested by Heesob Park <phasis@gmail.com>. Thank you!
[Bug #3606][ruby-core:31454]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
example is buggy and may not display anything by a race.
The patch is suggested by Heesob Parrk <phasis@gmail.com>.
Thank you! [Bug #3606][ruby-core:31454]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
and may cause deadlock. The patch is suggested by Heesob Park
<phasis@gmail.com>. Thank you! [Bug #3606][ruby-core:31454]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
no waiting thread. If there are 2 or more runnable threads,
the timer thread does polling. Avoid polling makes power save
for several computers (0.2W per a Ruby process, when I measured).
If outside-event such as signal or Thread#kill was occuerred
when the timer thread does not do polling, then wake-up
the timer thread using communication-pipe (the timer thread
waits this communication-pipe with select(2)).
The discussion about this modification can be found from the post
[ruby-core:33456] and other related posts.
Note that Eric Wong and KOSAKI Motohiro give us the huge
contributions for this modification. Thanks.
* thread_pthread.c (rb_thread_wakeup_timer_thread): add a function.
This function wakes up the timer thread using communication-pipe.
* thread.c (rb_thread_stop_timer_thread): add a parameter which
specify closing communication-pipe or not.
* thread.c (rb_thread_terminate_all): do not stop timer thread here
(ruby_cleanup() terminate timer thread).
* signal.c: wake up timer thread using
rb_thread_wakeup_timer_thread() from signal handler.
* eval.c (ruby_cleanup): use rb_thread_stop_timer_thread(1).
* process.c: use rb_thread_stop_timer_thread(0)
(reuse communication-pipe).
* thread_win32.c (rb_thread_wakeup_timer_thread): add a dummy
function.
* vm_core.h: add and fix decl. of functions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
backup. fix race condition which may results unexpected main thread's
status transition. see #4072
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c, eval.c, iseq.c, object.c, parse.y, proc.c, process.c,
thread.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c: don't
declare internal functions.
Note that rb_method_entry_eq() is defined in vm_method.c but
there was a declaration in proc.c with different const-ness.
Now it is declared in method.h with same const-ness to the
definition.
* object.c (rb_mod_module_exec): don't declare functions declared in
include/ruby/intern.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
cancelable.
* thread_win32.c (native_fd_select): new function to make select(2)
cancelable.
* thread_win32.c (rb_w32_check_interrupt): new function for checking
interrupt.
* win32/win32.c (rb_w32_select_with_thread): new function. cancelable
select(2).
* win32/win32.c (rb_w32_select): use above function internally.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread_pthread.c: remove HAVE_GVL_YIELD macro.
* thread_win32.c (gvl_yield): new. this fallback logic was moved from
rb_thread_schedule_rec().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
based on the patch by Eric Wong. [ruby-core:36156]
* vm_core.h (rb_thread_call_with_gvl): don't declare here.
* thread.c: include internal.h.
(rb_thread_execute_interrupts): new function.
* internal.h (rb_thread_execute_interrupts): declared.
(rb_thread_call_with_gvl): declared.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
type check to get rid of a double free when main Thread has singleton
class. [ruby-core:36741] [Bug #4828]
* thread.c (rb_obj_is_mutex): add a new utility function.
* vm.c (rb_obj_is_thread): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread_pthread.c (native_cond_timeout): new internal api.
it calculate a proper time for argument of native_cond_timedwait().
* thread_win32.c (native_cond_timeout): ditto.
* thread_pthread.c (thread_timer): use native_cond_timeout()
instead of get_ts.
* thread.c (lock_func): ditto.
* thread_pthread.c (get_ts): removed. use native_cond_timeout().
* thread.c (init_lock_timeout): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
no longer an alias of pthread_cond_t.
* thread_pthread.c: adapt new rb_thread_cond_t type.
* thread.c (mutex_alloc): ditto.
* thread_win32.c (native_cond_initialize): ditto.
* configure.in: add check for pthread_cond_attr_setclock() and
clockid_t type.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
if possible. based on a patch from Eric Wong. [ruby-core:36003].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/-ext-/wait_for_single_fd/test_wait_for_single_fd.rb
(TestWaitForSingleFD#test_wait_for_closed_pipe): test for it.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Now only Linux uses it.
The patch was written by Eric Wong. [Ruby 1.9 - Feature #4531]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread.c (select_single): select(2) based backend for rb_wait_for_single_fd().
* io.c (make_writeconv): use rb_wait_for_single_fd() instaed of
rb_thread_fd_select().
* io.c (rb_io_wait_readable): ditto.
* thread.c (rb_thread_wait_fd_rw): ditto.
* io.c (wait_readable): removed.
* thread.c (init_set_fd): new helper function.
* include/ruby/io.h (RB_WAITFD_IN, RB_WAITFD_PRI, RB_WAITFD_OUT):
new constant for rb_single_wait_fd().
The patch was written by Eric Wong. [Ruby 1.9 - Feature #4531]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31419 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Now do_select() is free from unexpected hangup if
HAVE_RB_FD_INIT=1 [Bug #4636]
* thread.c (rb_thread_fd_select, rb_thread_wait_fd_rw):
adapt new argument type.
* thread.c (rb_thread_select): make dummy implementation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e