* thread_pthread.c (set_nonblock): new helper function for set O_NONBLOCK.
* thread_pthread.c (rb_thread_create_timer_thread): set O_NONBLOCK
  to timer_thread_pipe[0] too.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread_pthread.c (USE_SLEEPY_TIMER_THREAD): use more accurate
  ifdef condtions.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread_pthread.c (timer_thread_sleep): use poll() instead of
  select(). select doesn't work if timer_thread_pipe[0] is
  greater than FD_SETSIZE.
* thread_pthread.c (USE_SLEEPY_TIMER_THREAD): add a dependency
  against poll.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread_pthread.c (consume_communication_pipe): retry when
  read returned CCP_READ_BUFF_SIZE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread_pthread.c (rb_thread_create_timer_thread): factor out
  creating communication pipe logic into separate function.
* thread_pthread.c (setup_communication_pipe): new helper function.
* thread_pthread.c (set_nonblock): moves a definition before
  setup_communication_pipe.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread_pthread.c (ubf_select): add to small comments why we
  need to call rb_thread_wakeup_timer_thread().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread_pthread.c (rb_thread_wakeup_timer_thread_fd): add fd
  argument and remove hardcoded dependency of timer_thread_pipe[1].
* thread_pthread.c (consume_communication_pipe): add fd argument.
* thread_pthread.c (close_communication_pipe): ditto.

* thread_pthread.c (timer_thread_sleep): adjust the above changes.

* thread_pthread.c (setup_communication_pipe_internal): factor
  out pipe initialize logic.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread_pthread.c (ARRAY_SIZE): new.
* thread_pthread.c (gvl_acquire_common): use low priority
  notification for avoiding timer thread interval confusion.
  If we use timer_thread_pipe[1], every gvl_yield() request
  one more gvl_yield(). It lead to thread starvation.
  [Bug #7999] [ruby-core:53095]
* thread_pthread.c (rb_reserved_fd_p): adds timer_thread_pipe_low
  to reserved fds.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c (rb_update_max_fd): use ATOMIC_CAS because this function
  is used from timer thread too.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/thread/test_queue.rb (TestQueue#test_thr_kill): reduce
  iterations from 2000 to 250. When running on uniprocessor
  systems, every th.kill needs TIME_QUANTUM_USEC time (i.e.
  100msec on posix systems). Because, "r.read 1" is 3 steps
  operations that 1) release GVL 2) read 3) acquire gvl and
  (1) invoke context switch to main thread. and then, main
  thread's th.kill resume (1), but not (2). Thus read interrupt
  need TIME_QUANTUM_USEC. Then maximum iteration is 30sec/100msec
  = 300.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e