Граф коммитов

641 Коммитов

Автор SHA1 Сообщение Дата
kosaki 90425153fb * thread.c (rb_mutex_unlock): Mutex#unlock no longer raise
an exception even if uses on trap. [Bug #8891]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-10 23:21:17 +00:00
glass e334bb2ce5 * common.mk: use RUNRUBY instead of MINIRUBY because MINIRUBY can't
require extension libraries. The patch is from nobu
  (Nobuyoshi Nakada).

* ext/thread/extconf.rb: for build ext/thread/thread.c.

* include/ruby/intern.h: ditto.

* thread.c: ditto.

* lib/thread.rb: removed and replaced by ext/thread/thread.c.

* ext/thread/thread.c: Queue, SizedQueue and ConditionVariable
  implementations in C. This patch is based on patches from panaggio
  (Ricardo Panaggio) and funny_falcon (Yura Sokolov) and  ko1
  (Koichi Sasada). [ruby-core:31513] [Feature #3620]

* test/thread/test_queue.rb (test_queue_thread_raise): add a test for
  ensuring that killed thread should be removed from waiting threads.
  It is based on a code by ko1 (Koichi Sasada). [ruby-core:45950]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-06 15:15:07 +00:00
ktsj 04f0de74dd * error.c, file.c, gc.c, hash.c, thread.c, variable.c, vm_eval.c, bin/erb:
$SAFE=4 is obsolete.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-18 10:36:51 +00:00
ko1 2391ee2c61 * thread.c (rb_threadptr_pending_interrupt_check_mask):
use RARRAY_RAWPTR() instead of RARRAY_PTR() because
  there is no new reference.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-08 11:00:06 +00:00
ko1 7a23eb1c41 * thread.c (thread_start_func_2): use RARRAY_RAWPTR() instead of
RARRAY_PTR() because there is no new reference.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-07 03:59:30 +00:00
ko1 4d3feac974 * thread_(pthread|win32).h: rename rb_thread_cond_t to
rb_nativethread_cond_t.
* thread.c, thread_pthread.c, thread_win32.c, vm_core.h: catch up
  renaming.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-23 10:50:32 +00:00
ko1 bd058912da * thread_native.h: added.
Move native thread related lines from vm_core.h.
  And declare several functions "rb_nativethread_lock_*",
  manipulate locking.
* common.mk: add thread_native.h.
* thread.c: add functions "rb_nativethread_lock_*".
* thraed.c, thread_[pthread,win32].[ch]: rename rb_thread_lock_t
  to rb_nativethread_lock_t to make it clear that this lock is for
  native thraeds, not for ruby threads.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-23 09:53:14 +00:00
zzak 89d8d7694c * thread.c (mutex_sleep): [DOC] Awake thread will reacquire lock
By Tim Abdulla [Fixes GH-342] https://github.com/ruby/ruby/pull/342


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15 01:56:52 +00:00
nobu ea2b115efd internal.h: use built-in encoding indexes
* internal.h (rb_{ascii8bit,utf8,usascii}_encindex): use built-in
  encoding indexes for optimization.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-02 08:22:30 +00:00
shugo 1f828497d1 * safe.c (rb_set_safe_level, safe_setter): raise an ArgumentError
when $SAFE is set to 4.  $SAFE=4 is now obsolete.
  [ruby-core:55222] [Feature #8468]

* object.c (rb_obj_untrusted, rb_obj_untrust, rb_obj_trust):
  Kernel#untrusted?, untrust, and trust are now deprecated.
  Their behavior is same as tainted?, taint, and untaint,
  respectively.

* include/ruby/ruby.h (OBJ_UNTRUSTED, OBJ_UNTRUST): OBJ_UNTRUSTED()
  and OBJ_UNTRUST() are aliases of OBJ_TAINTED() and OBJ_TAINT(),
  respectively.

* array.c, class.c, debug.c, dir.c, encoding.c, error.c, eval.c,
  ext/curses/curses.c, ext/dbm/dbm.c, ext/dl/cfunc.c,
  ext/dl/cptr.c, ext/dl/dl.c, ext/etc/etc.c, ext/fiddle/fiddle.c,
  ext/fiddle/pointer.c, ext/gdbm/gdbm.c, ext/readline/readline.c,
  ext/sdbm/init.c, ext/socket/ancdata.c, ext/socket/basicsocket.c,
  ext/socket/socket.c, ext/socket/udpsocket.c,
  ext/stringio/stringio.c, ext/syslog/syslog.c, ext/tk/tcltklib.c,
  ext/win32ole/win32ole.c, file.c, gc.c, hash.c, io.c, iseq.c,
  load.c, marshal.c, object.c, proc.c, process.c, random.c, re.c,
  safe.c, string.c, thread.c, transcode.c, variable.c,
  vm_insnhelper.c, vm_method.c, vm_trace.c: remove code for
  $SAFE=4.

* test/dl/test_dl2.rb, test/erb/test_erb.rb,
  test/readline/test_readline.rb,
  test/readline/test_readline_history.rb, test/ruby/test_alias.rb,
  test/ruby/test_array.rb, test/ruby/test_dir.rb,
  test/ruby/test_encoding.rb, test/ruby/test_env.rb,
  test/ruby/test_eval.rb, test/ruby/test_exception.rb,
  test/ruby/test_file_exhaustive.rb, test/ruby/test_hash.rb,
  test/ruby/test_io.rb, test/ruby/test_method.rb,
  test/ruby/test_module.rb, test/ruby/test_object.rb,
  test/ruby/test_pack.rb, test/ruby/test_rand.rb,
  test/ruby/test_regexp.rb, test/ruby/test_settracefunc.rb,
  test/ruby/test_struct.rb, test/ruby/test_thread.rb,
  test/ruby/test_time.rb: remove tests for $SAFE=4.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12 14:20:51 +00:00
ko1 680f0b5ba4 * include/ruby/ruby.h, gc.c, vm_trace.c: add internal events.
* RUBY_INTERNAL_EVENT_NEWOBJ: object created.
* RUBY_INTERNAL_EVENT_FREE: object freeed.
* RUBY_INTERNAL_EVENT_GC_START: GC started.
  And rename `RUBY_EVENT_SWITCH' to `RUBY_INTERNAL_EVENT_SWITCH'.
  Internal events can not invoke any Ruby program because the tracing
  timing may be critical (under huge restriction).
  These events can be hooked only by C-extensions.
  We recommend to use rb_potponed_job_register() API to call Ruby
  program safely.
  This change is mostly written by Aman Gupta (tmm1).
  https://bugs.ruby-lang.org/issues/8107#note-12
  [Feature #8107]
* include/ruby/debug.h, vm_trace.c: added two new APIs.
* rb_tracearg_event_flag() returns rb_event_flag_t of this event.
* rb_tracearg_object() returns created/freeed object.
* ext/-test-/tracepoint/extconf.rb,
  ext/-test-/tracepoint/tracepoint.c,
  test/-ext-/tracepoint/test_tracepoint.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40946 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-27 00:21:02 +00:00
ko1 e2793a908e * include/ruby/debug.h, vm_trace.c: add rb_postponed_job API.
Postponed jobs are registered with this API. Registered jobs
  are invoked at `ruby-running-safe-point' as soon as possible.
  This timing is completely same as finalizer timing.
  There are two APIs:
* rb_postponed_job_register(flags, func, data): register a
  postponed job with data. flags are reserved.
* rb_postponed_job_register_one(flags, func, data): same as
  `rb_postponed_job_register', but only one `func' job is
  registered (skip if `func' is already registered).
  This change is mostly written by Aman Gupta (tmm1).
  https://bugs.ruby-lang.org/issues/8107#note-15
  [Feature #8107]
* gc.c: use postponed job API for finalizer.
* common.mk: add dependency from vm_trace.c to debug.h.
* ext/-test-/postponed_job/extconf.rb, postponed_job.c,
  test/-ext-/postponed_job/test_postponed_job.rb: add a test.
* thread.c: implement postponed API.
* vm_core.h: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40940 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-26 21:30:44 +00:00
ko1 c4c821a7d7 * hash.c (rb_hash_tbl_raw), internal.h: added.
Returns st_table without shading hash.
* array.c: use rb_hash_tbl_raw() for read-only purpose.
* compile.c (iseq_compile_each): ditto.
* gc.c (count_objects): ditto.
* insns.def: ditto.
* process.c: ditto.
* thread.c (clear_coverage): ditto.
* vm_insnhelper.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-26 16:19:04 +00:00
ktsj edb98f8b91 fix typos. Patch by k_takata.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-19 03:10:21 +00:00
ko1 83aba04862 * include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'.
  This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
  This function reveal interal (hidden) object by rb_obj_hide().
  Note that do not change class before and after hiding.
  Only permitted example is:
  klass = RBASIC_CLASS(obj);
  rb_obj_hide(obj);
  ....
  rb_obj_reveal(obj, klass);
  TODO: API design. rb_obj_reveal() should be replaced with others.
  TODO: modify constified variables using cast may be harmful for
  compiler's analysis and optimizaton.
  Any idea to prohibt inserting RBasic::klass directly?
  If rename RBasic::klass and force to use RBASIC_CLASS(obj),
  then all codes such as `RBASIC(obj)->klass' will be
  compilation error. Is it acceptable? (We have similar
  experience at Ruby 1.9,
  for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
  object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
  without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
  file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
  parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
  string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
  Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
  ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 10:49:11 +00:00
ko1 aacd771046 * *.c, parse.y, insns.def: use RARRAY_AREF/ASET macro
instead of using RARRAY_PTR().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 09:56:22 +00:00
nobu 31457774a8 thread.c: id locals
* thread.c (id_locals): use cached ID.
* vm.c (ruby_thread_init): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-02 07:55:50 +00:00
akr e3e9c5682e Add comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-29 09:01:44 +00:00
eregon 5c1d4c2ade * thread.c: fix typos and documentation
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-27 10:33:44 +00:00
akr d907adecd9 * internal.h (SIGNED_INTEGER_TYPE_P): New macro.
(SIGNED_INTEGER_MAX): Ditto.
  (SIGNED_INTEGER_MIN): Ditto.
  (UNSIGNED_INTEGER_MAX): Ditto.
  (TIMET_MAX): Use SIGNED_INTEGER_MAX and UNSIGNED_INTEGER_MAX.
  (TIMET_MIN): Use SIGNED_INTEGER_MIN.

* thread.c (TIMEVAL_SEC_MAX): Use SIGNED_INTEGER_MAX.
  (TIMEVAL_SEC_MIN): Use SIGNED_INTEGER_MIN.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-27 06:52:17 +00:00
akr e88a692a88 * thread.c (TIMEVAL_SEC_MAX, TIMEVAL_SEC_MIN): Consider environments,
sizeof(time_t) is smaller than sizeof(tv_sec), such as
  OpenBSD 5.2 (amd64).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-27 03:30:50 +00:00
nobu 9e39bc1a08 thread.c: fix overflow on Windows
* thread.c (sleep_timeval): get rid of overflow on Windows where
  timeval.tv_sec is not time_t but mere long.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-17 01:58:25 +00:00
akr 712c7168bf * internal.h (MUL_OVERFLOW_SIGNED_INTEGER_P): New macro.
(MUL_OVERFLOW_FIXNUM_P): Ditto.
  (MUL_OVERFLOW_LONG_P): Ditto.

* array.c (rb_ary_product): Don't overflow on signed integer
  multiplication.

* numeric.c (fix_mul): Ditto.
  (int_pow): Ditto.

* rational.c (f_imul): Ditto.

* insns.def (opt_mult): Ditto.

* thread.c (sleep_timeval): Don't overflow on signed integer addition.

* bignum.c (rb_int2big): Don't overflow on signed integer negation.
  (rb_big2ulong): Ditto.
  (rb_big2long): Ditto.
  (rb_big2ull): Ditto.
  (rb_big2ll): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-09 11:39:53 +00:00
hsbt 43a1629625 Fix documentation by @jc00ke [fix GH-278]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-09 00:26:22 +00:00
nobu 11391aa01b thread.c: no allocate before deleting
* thread.c (rb_thread_local_aset): no needs to allocate local_storage
  before deleting.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-05 15:21:02 +00:00
nobu 8074844065 thread.c: avoid inadvertent symbol creation
* thread.c (rb_thread_aref): avoid inadvertent symbol creation.
  (rb_thread_variable_get): ditto.
  (rb_thread_key_p): ditto.
  (rb_thread_variable_p): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-04 05:37:21 +00:00
nobu f00035a4f7 thread.c: error message
* thread.c (rb_thread_variable_get): fix error message.  getter
  doesn't modify thread variables.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-04 05:37:19 +00:00
nobu b5583577d4 thread.c: TYPEOF_TIMEVAL_TV_SEC
* configure.in (TYPEOF_TIMEVAL_TV_SEC): check for x64-mingw, where
  timeval.tv_sec is not time_t.

* thread.c (double2timeval): use TYPEOF_TIMEVAL_TV_SEC to get rid of
  overflow.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-30 21:08:42 +00:00
nobu 77ff241fa0 timev.h: move time_t stuffs
* timev.h (TYPEOF_TIMEVAL_TV_SEC, unsigned_time_t): move from time.c.

* thread.c: use definitions in timev.h.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40011 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-30 21:08:36 +00:00
nobu f2e1bfb897 thread.c: format specifiers for time_t
* thread.c (sleep_timeval): fix format specifiers for time_t.

* time.c (DEBUG_REPORT_GUESSRANGE): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40010 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-30 21:08:34 +00:00
nobu 99155e20a0 thread.c: Mutex#synchronize no block params
* thread.c (rb_mutex_synchronize_m): yield no block params.  patch by
  splattael (Peter Suschlik) in [ruby-core:53773] [Bug #8097].
  fix GH-266.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-29 13:09:52 +00:00
akr 3dcdfcf884 * internal.h (TIMET_MAX_PLUS_ONE): Defined.
* thread.c (double2timeval): Saturate out-of-range values. 



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39948 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-26 15:30:27 +00:00
akr bfb0edbad2 * internal.h: Define TIMET_MAX and TIMET_MIN here.
* time.c: Remove TIMET_MAX and TIMET_MIN definitions.

* thread.c: Ditto.

* thread_pthread.c: Remove TIMET_MAX definition.

* thread_win32.c: Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-26 14:45:55 +00:00
akr 79f7521e9b * thread.c (double2timeval): convert the infinity to TIME_MAX to avoid
SEGV by Thread.new {}.join(Float::INFINITY) on
  Debian GNU/Linux (amd64).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-26 13:16:31 +00:00
nobu 5de144f3a5 thread.c: fix deadlock
* thread.c (ruby_kill): get rid of deadlock on signal 0.
  [ruby-dev:47182] [Bug #8137]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-21 14:17:10 +00:00
kosaki 8c52515eaa * thread.c (ruby_kill): added a few comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-19 18:26:27 +00:00
kosaki c9073822c2 * thread.c (ruby_kill): release GVL while waiting signal delivered.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-19 18:26:11 +00:00
usa d617690a65 * ruby_kill (internal.h, thread.c): use rb_pid_t instead of pid_t.
this fixes the build failure of mswin introduced at r39819.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-19 10:51:49 +00:00
kosaki 4ea96ece84 * internal.h: added a declaration of ruby_kill().
* thread.c (ruby_kill): helper function of kill().

* signal.c (rb_f_kill): use ruby_kill() instead of kill().
* signal.c (rb_f_kill): call rb_thread_execute_interrupts()
  to ensure that make SignalException if sent a signal
  to myself. [Bug #7951] [ruby-core:52864]

* vm_core.h (typedef struct rb_thread_struct): added
  th->interrupt_cond.
* thread.c (rb_threadptr_interrupt_common): added to
  initialization of th->interrupt_cond.
* thread.c (thread_create_core): ditto.

* test/ruby/test_signal.rb (TestSignal#test_hup_me): test for
  the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-19 04:40:22 +00:00
kosaki 92b367e069 * thread.c: disabled _FORTIFY_SOURCE for avoid to hit glibc bug.
[Bug #8080] [ruby-core:53349]
* test/ruby/test_io.rb (TestIO#test_io_select_with_many_files):
  test for the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-16 05:07:28 +00:00
nobu 2d1c94a18d prefix global symbols
* iseq.c (rb_insn_operand_intern): prefix global symbols.

* numeric.c (ruby_num_interval_step_size): ditto.

* vm_backtrace.c (rb_vm_backtrace_str_ary),
  (rb_vm_backtrace_location_ary, rb_vm_thread_backtrace),
  (rb_vm_thread_backtrace_locations): ditto.

* vm_trace.c (rb_vm_trace_mark_event_hooks): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-06 06:30:03 +00:00
zzak 4e040aa6ac * thread.c: rdoc formatting for Thread, ThreadGroup, and ThreadError
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-27 20:36:59 +00:00
zzak f7a7138d5b * thread.c (rb_thread_wakeup): rdoc formatting
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-27 03:58:36 +00:00
zzak e016ec1707 thread.c (rb_thread_group): rdoc formatting
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-27 03:53:13 +00:00
zzak 7c4084f9fb * thread.c (thread_raise_m): rdoc formatting
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-27 01:24:08 +00:00
nobu eed06bb043 thread.c: remove unnecessary sentence
* thread.c (thread_start): initialize method is not concerned with
  Thread.start and Thread.fork.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-25 04:10:54 +00:00
zzak 84e8862c56 * thread.c: Document Thread::new, clean up ::fork and mention calling
super if subclassing Thread


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39484 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-25 03:50:20 +00:00
zzak 1f9fa7c62f * thread.c: Document ThreadGroup::Default
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-24 05:29:06 +00:00
zzak 5feede6f3b * thread.c: Grammar for #backtrace_locations and ::handle_interrupt
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-24 05:23:51 +00:00
zzak a153ce31a1 * thread.c: Documentation for Thread#backtrace_locations
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-23 07:52:46 +00:00
zzak 5f2e433813 * thread.c: Improved rdoc for ::handle_interrupt, ::pending_interrupt?
and #pending_interrupt?


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-23 07:00:51 +00:00
takano32 bd0be3c4fd Thu Jan 10 19:39:05 2013 TAKANO `takano32' Mitsuhiro <tak@no32.tk>
* thread.c: fix RB_GC_SAVE_MACHINE_REGISTER_STACK define for ia64.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-10 10:45:05 +00:00
usa 2f345f9de6 * ChangeLog: revert a part of r38595. 'iff' means 'if and only if', not typo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-25 10:45:20 +00:00
usa a3d9672407 * bignum.c, include/ruby/intern.h (rb_big_eql): exported.
* thread.c (recursive_check): object_id maybe a Bignum, not Fixnum on
  LLP64.  see also r38493 and r38548.
  reported by Heesob Park at [ruby-core:51083] [Bug #7607], and patched
  by shirosaki at [ruby-core:51095]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-25 10:14:12 +00:00
ko1 48f320194a add empty line for style.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-25 07:17:55 +00:00
ko1 0f9b33c793 * thread.c: rename methods:
from Thread.async_interrupt_timing to Thread.handle_interrupt,
  from Thread.async_interrupted? to Thread.pending_interrupt?.
  Also rename option from `defer' to `never'.
  [ruby-core:51074] [ruby-trunk - Feature #6762]
* vm_core.c, thread.c: rename functions and data structure
  `async_errinfo' to `pending_interrupt'.
* thread.c: add global variables sym_immediate, sym_on_blocking and
  sym_never.
* cont.c, process.c, vm.c, signal.c: ditto.
* lib/sync.rb, lib/thread.rb: catch up this renaming.
* test/ruby/test_thread.rb: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-23 10:18:58 +00:00
nobu 482bf47d1f thread.c: ignore result of blocking_region_begin
* thread.c (BLOCKING_REGION): if fail_if_interrupted is false ignore
  the result of blocking_region_begin(), since it always is true in
  that case.  suppress "uninitialized" warnings.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-23 05:35:15 +00:00
nagachika 6a35c26b2d * cont.c (rb_fiber_start): in case of jump with TAG_FATAL,
enqueue error into async_errinfo_queue, because you cannot call
  TH_TAG_JUMP() in this function. [ruby-dev:45218]  [Bug #5993]

* thread.c (rb_threadptr_execute_interrupts): now INT2FIX(TAG_FATAL)
  can be popped from async_errinfo_queue.

* vm.c (rb_vm_make_jump_tag_but_local_jump): revert r38441.
  rb_vm_make_jump_tag_but_local_jump() shouldn't return exception
  in case of state == TAG_FATAL.

* test/ruby/test_fiber.rb (test_exit_in_fiber): fix a test to illuminate
  Thread.exit should terminate current Thread.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-22 06:45:28 +00:00
kosaki b842263696 style fix.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38467 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-19 11:19:37 +00:00
kosaki 005db82d36 * thread.c (rb_thread_wait_fd_rw): fix infinite loop bug.
rb_wait_for_single_fd() never return positive number.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-18 10:07:05 +00:00
nobu 2ca5e8eeab * parse.y (yycompile0): adjust indent.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-15 06:10:01 +00:00
kosaki e78d4e69fe * thread.c (rb_mutex_owned_p): remove static.
* io.c (io_flush_buffer): don't hold mutex if already have.
  Now recursive lock may occur when following scenario.
  fptr_finalize -> finish_writeconv_sync -> finish_writeconv
  -> io_fflush.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-15 05:40:18 +00:00
kosaki 47fa79203d * thread.c (rb_thread_wait_fd_rw): remove silly rb_thread_alone()
check.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-15 05:39:25 +00:00
nobu ce6a2c7fac thread.c: revert r38382 but deprecate rb_thread_polling()
* thread.c (rb_thread_polling): revert but deprecate.
* include/ruby/intern.h (rb_thread_polling): deprecate.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-15 01:22:44 +00:00
kosaki a24f2d9915 * file.c (rb_file_flock): use rb_thread_wait_for() instead of
rb_thread_polling(). When getting EAGAIN, we need to wait a
  while even if no multi threading.
* thread.c (sleep_for_polling, rb_thread_polling) removed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-14 18:08:40 +00:00
kosaki fe6b2e20e9 * thread.c (rb_uninterruptible): helper function for providing
temporary async_interrupt_timing(Object => :defer)

* io.c (rb_f_p): use rb_uninterruptible.
* io.c (rb_f_p_internal): helper function for rb_f_p().
* io.c (struct rb_f_p_arg): new struct for rb_f_p_internal.

* test/ruby/test_thread.rb (test_async_interrupt_and_p): test for
  the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-05 19:37:49 +00:00
tarui 17a11774ca * thread.c (rb_thread_s_async_interrupt_timing): have to check ints before jumpping out.
* test/ruby/test_thread.rb (test_async_interrupt_with_return): add test
	  rescue has to catch a queued async exception at the time of return.
	* test/ruby/test_thread.rb (test_async_interrupt_with_break): add test
	  rescue has to catch a queued async exception at the time of break.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-05 09:54:58 +00:00
tarui 64f634f1de * vm_core.h (RUBY_VM_CHECK_INTS_BLOCKING): check async queue everytime.
* thread.c (sleep_forever): check RUBY_VM_CHECK_INTS_BLOCKING first.
        * thread.c (sleep_timeval): ditto.
        * test/ruby/test_thread.rb (test_async_interrupt_blocking): add a test
          exceptions are correctly defared and raised on :on_blocking context.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-04 18:38:21 +00:00
kosaki 70d603a412 supress warning
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-04 16:06:43 +00:00
kosaki 3765f668c6 supress warning
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-04 16:05:40 +00:00
kosaki bbfbf662cc * thread.c (rb_mutex_owned_p): new method that return current
thread have the target mutex or not. [Feature #7505] [ruby-dev:46697]
* test/ruby/test_thread.rb (test_mutex_owned, test_mutex_owned2):
  test for the above.
* NEWS: new for the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-04 16:02:07 +00:00
tarui c1e6052bfe * thread.c (RB_GC_SAVE_MACHINE_CONTEXT, rb_gc_save_machine_context):
extract rb_gc_save_machine_context to RB_GC_SAVE_MACHINE_CONTEXT.
	  NOTE: machine_regs and machine_stack_end must be set in current scope.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-02 10:28:27 +00:00
tarui d64a73e1dd revert r38141 for stack problem
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-02 08:56:27 +00:00
tarui 1e88b393e0 * thread.c (RB_GC_SAVE_MACHINE_CONTEXT, rb_gc_save_machine_context):
Don't set machine_regs and machine_stack_end with a different scope.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-02 08:45:14 +00:00
ko1 e742a446c8 * thread.c (Thread.async_interrupt_timing): fix RDoc.
:never is not used any more.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30 18:47:00 +00:00
kosaki a113ab64b2 * thread.c (rb_threadptr_interrupt_mask, async_interrupt_timing_func):
merge into them into rb_thread_s_async_interrupt_timing.
* thread.c (rb_thread_s_async_interrupt_timing): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30 17:39:59 +00:00
kosaki 279cd29b1b * thread.c (rb_threadptr_interrupt_mask): add argument check.
* thread.c (async_interrupt_timing_arg_check_i): helper function
  for the above.
* test/ruby/test_thread.rb (test_async_interrupt_timing_invalid_argument):
  test for the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30 17:39:48 +00:00
kosaki 15b25acd25 * vm_core.h (rb_vm_struct): add thread_destruct_lock field.
* thread.c (Init_Thread): ditto.
* thread.c (rb_vm_gvl_destroy): ditto.

* thread.c (thread_start_func_2): make sure vm->running_thread
  don't point to dead thread.
* thread.c (timer_thread_function): close a race against thead
  destruction. [Bug #4911][ruby-dev:43859]

* vm_core.h (rb_thread_set_current): reset running time of
  current thread instead of previous thread. We no longer
  assume previous running thread still live.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30 13:52:34 +00:00
kosaki 2e72d1c323 revert r35486 (add rb_thread_t#yeiling field). because it doesn't help
to close a race.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30 13:52:24 +00:00
ko1 bb4410a289 * thread.c: TracePoint#self returns invoking/exitting thread object
at thread_begin/end event.
* test/ruby/test_settracefunc.rb: fix test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30 11:50:26 +00:00
ko1 719e0cd530 * thread.c: rename Thread.control_interrupt
to Thread.async_interrupt_timing.
  The option name `:never' is also changed to  `:defer'.
  [ruby-core:50375] [ruby-trunk - Feature #6762]
* thread.c: remove Thread.check_interrupt.
  This method is difficult to understand by name.
* thraed.c: add Thread.async_interrupted?.
  This method check any defered async interrupts.
* test/ruby/test_thread.rb: change tests for above.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30 09:28:35 +00:00
ko1 c86379402c * thread.c (rb_thread_interrupted): avoid warning of
implicit conversion.
* thread.c (rb_threadptr_execute_interrupts): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 22:44:51 +00:00
ko1 4db8340398 [EXPERIMENTAL: NEED DISCUSS]
* vm_trace.c: add events
* :thread_begin - hook at thread beggining.
* :thead_end - hook at thread ending.
* :b_call - hook at block enter.
* :b_return - hook at block leave.
  This change slow down block invocation.
  Please try and give us feedback until 2.0 code freeze.
* include/ruby/ruby.h: ditto.
* compile.c (rb_iseq_compile_node): ditto.
* insns.def: ditto.
* thread.c: ditto.
* vm.c: ditto.
* include/ruby/debug.h: add a comment.
* test/ruby/test_settracefunc.rb: add a tests.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 22:28:16 +00:00
kosaki c058d821f8 Revert r37956: thread.c (thread_start_func_2): small cleanups.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 02:50:11 +00:00
kosaki 989c529c89 * thread.c (thread_start_func_2): remove unused code. When
th->safe_level == 4, th->errinfo never be thrown. So, to
  create new exception makes no sense.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 02:09:36 +00:00
naruse d1dfebc05a Revert r37953: thread.c (thread_start_func_2): remove unused code. security
This sticks at bootstraptest/test_fork.rb:24 on FreeBSD and darwin.
http://fb.rubyci.org/~chkbuild/ruby-trunk/log/20121128T230302Z.log.html.gz
http://a.mrkn.jp/~mrkn/chkbuild/sl/ruby-trunk-m64-gcc42-o0/log/20121128T235908Z.log.html.gz

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 01:11:47 +00:00
naruse e2779a53ef * thread.c (do_select): suppress warning (uninitialized value warning)
with UNINITIALIZED_VAR().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 00:52:51 +00:00
kosaki b76b6b5c98 * thread.c (thread_start_func_2): small cleanups.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 21:55:26 +00:00
kosaki 5e606aee2f * thread.c (thread_start_func_2): remove unused code.
this function never be used for main thread.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 21:55:14 +00:00
kosaki fdda95ed8c * thread.c (thread_start_func_2): remove unused code.
errinfo = th->errinfo; and errinfo = rb_errinfo(); are
  the same.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 21:55:03 +00:00
kosaki 1d207fcff0 * thread.c (thread_start_func_2): remove unused code. security
level is checked before rb_eSecurityError raises.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 21:54:52 +00:00
ko1 09f9aa4385 * thread.c (rb_mutex_sleep): fix to allow spurious wakeup.
* NEWS: write about spurious wakeup.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 14:40:00 +00:00
ko1 9d0de48e66 * include/ruby/thread.h (rb_thread_call_without_gvl2): change
meaning of function.
  This function is called with same parameters of
  `rb_thread_call_without_gvl()'.
  However, if interrupts are detected, when return immediately.
* thread.c: implement `rb_thread_call_without_gvl2()'.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 13:01:25 +00:00
tarui f5dc27aa77 * thread.c (thread_join_sleep): check spurious wakeup by itself for
corresponding status change in trap context.
	* vm_core.h (struct rb_thread_struct): add rb_thread_list_t and use as join_list for
	reentry by trap context.
	* thread.c (thread_start_func_2): ditto.
	* thread.c (remove_from_join_list): ditto.
	* thread.c (rb_thread_atfork): ditto.
	* thread.c (thread_join): ditto. & remove trap handler check.
	* thread.c (sleep_forever): add argument : spurious_check.
	* thread.c (sleep_timeval): ditto.
	* thread.c (rb_thread_sleep_forever): set spurious_check.
	* thread.c (rb_thread_sleep_deadly): ditto.
	* thread.c (sleep_for_polling): ditto.
	* thread.c (rb_thread_wait_for): ditto.
	* thread.c (sleep_wait_for_interrupt): bypass spurious_check.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 12:34:15 +00:00
kosaki 9cbf473287 * vm_core.h (enum rb_thread_status): remove THREAD_TO_KILL
* vm_core.h (struct rb_thread_struct): add to_kill field
* thread.c (terminate_i): convert THREAD_TO_KILL to to_kill.
* thread.c (rb_threadptr_to_kill): ditto.
* thread.c (rb_thread_kill): ditto.
* thread.c (rb_thread_wakeup_alive): ditto.
* thread.c (thread_list_i): ditto.
* thread.c (static const char): ditto.
* thread.c (thread_status_name): ditto.
* thread.c (rb_thread_status): ditto.
* thread.c (rb_thread_inspect): ditto.
* vm_backtrace.c (thread_backtrace_to_ary): ditto.

* thread.c (rb_threadptr_execute_interrupts): fix thread status
  overwritten issue. [Bug #7450] [ruby-core:50249]

* test/ruby/test_thread.rb (test_hread_status_raise_after_kill):
  test for the above.
* test/ruby/test_thread.rb (test_thread_status_in_trap): test for
  thread status in trap.
* test/ruby/test_thread.rb (test_status_and_stop_p): remove
  Thread.control_interrupt unsafe test. Thread#kill no longer
  changes thread status. Instead of, Thread#kill receiver changes
  their own status when receiving kill signal.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 08:31:03 +00:00
kosaki b8a1e36201 * thread.c (struct rb_mutex_struct): add allow_trap field.
* internal.h (rb_mutex_allow_trap): added.
* thread.c (rb_mutex_lock, rb_mutex_unlock): check mutex->allow_trap.
* thread.c (mutex_sleep): remove trap check because it uses
  rb_mutex_lock and rb_mutex_unlock internally.
* thread.c (rb_mutex_allow_trap): new helper function for the above.

* io.c (io_binwrite): mark fptr->write_lock as writable in trap.

* test/ruby/test_signal.rb (test_trap_puts): test for the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 08:30:51 +00:00
kosaki 835d24f637 * thread.c (rb_mutex_lock): moved trap context check from
rb_mutex_trylock because try_lock have no change to make
  a deadlock.
* thread.c (rb_mutex_trylock): ditto.
* NEWS: news for the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 05:40:54 +00:00
kosaki 8111b32d68 * thread.c (thread_s_new): uses main_thread->status instead of
th->inhibit_thread_creation for preventing thread creation.
* vm_core.h (rb_vm_struct): remove inhibit_thread_creation field.
* thread.c (rb_thread_terminate_all): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 04:43:15 +00:00
kosaki 694c77633c * thread.c (thread_join): A trap handler check was moved from
thread_join_m because Thread#value should be raised an exception
  too.
* thread.c (thread_join_m): remove trap handler check.
* test/ruby/test_thread.rb (test_thread_join_in_trap): add test
  for thread#value.
* NEWS: documentation fix for the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37918 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 04:09:38 +00:00
ko1 c72f0daa87 * thread.c (rb_thread_terminate_all): retry broadcast only when
an exception is raised.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-27 03:18:29 +00:00
ko1 2f9ee7af47 * thread.c (rb_thread_terminate_all): broadcast terminate event
not only an interrupt exception but any exceptions.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-27 03:04:36 +00:00
kosaki 863e087326 * thread.c (rb_thread_terminate_all): suppress a warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-27 02:00:29 +00:00
kosaki b1a18cf49b * thread.c (thread_join): raises ThreadError if target therad
is a main thread.
* test/ruby/test_thread.rb (test_thread_join_main_thread):
  test for the above.
* NEWS: news for the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-27 02:00:19 +00:00
kosaki 8079f8a6f2 * thread.c (thread_join): raises ThreadError if target thread
is a current thread.
* test/ruby/test_thread.rb (test_thread_join_current):
  test for the above.
* NEWS: news for the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-27 02:00:09 +00:00
kosaki a916278900 * thread.c (rb_thread_terminate_all): broadcast eTerminateSignal
again when Ctrl-C was pressed. [Feature #1952] [ruby-dev:39107]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 23:08:36 +00:00
kosaki 253938067a * thread.c (rb_thread_terminate_all): add RUBY_VM_CHECK_INTS_BLOCKING().
Otherwise the loop in this function behave as busy loop because
  native_sleep() return immediately when RUBY_VM_INTERRUPTED() is true.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 22:49:36 +00:00
kosaki 5b238e8dc7 * thread.c (rb_mutex_trylock, rb_mutex_unlock, mutex_sleep):
raises ThreadError if called from trap handler as Thread#join.
* NEWS: news fot the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 15:17:01 +00:00
kosaki 39d38ff82f * thread.c (rb_thread_terminate_all): use native_sleep() instead
of rb_thread_schedule(). Otherwise, it consume 100% cpu meaninglessly.
  [Bug #5368] [ruby-dev:44546]
* thread.c (thread_start_func_2): last sub-thread wakes up main thread.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 13:47:23 +00:00
kosaki 66e2e6ee69 * vm_core.h (RUBY_VM_SET_TIMER_INTERRUPT, RUBY_VM_SET_INTERRUPT)
(RUBY_VM_SET_FINALIZER_INTERRUPT, RUBY_VM_SET_TRAP_INTERRUPT)
(RUBY_VM_INTERRUPTED): use enum symbol instead of immediate value.
* thread.c (thread_join_m, rb_threadptr_execute_interrupts): ditto.
* signal.c (signal_exec): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 12:17:10 +00:00
kosaki 58543f00b6 * thread.c (thread_join_m): use th->interrupt_mask instead of
th->in_trap.

* vm_core.h (struct rb_thread_struct): remove in_trap member.
* signal.c (signal_exec): ditto.
* thread.c (thread_create_core): ditto.
* thread.c (Init_Thread): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 11:45:39 +00:00
kosaki 6190bb4d8a * ruby_atomic.h (ATOMIC_CAS): new macro for compare-and-exchange.
* vm_core.h (struct rb_thread_struct): add interrupt_mask member.
* thread.c (thread_create_core, Init_Thread): initialize
  th->thread_mask.

* vm_core.h (RUBY_VM_INTERRUPTED_ANY): new macro for avoiding
  bare th->interrupt_flag.
* vm_core.h (RUBY_VM_INTERRUPTED, RUBY_VM_INTERRUPTED): check
  th->interrupt_mask.
* thread.c (set_unblock_function, rb_thread_schedule): replace
  th->interrupt_flag with RUBY_VM_INTERRUPTED_ANY()

* signal.c (signal_exec): set up thread->interrupt_mask for
  preventing recursive trap handler.
* vm_core.h (RUBY_VM_CHECK_INTS, RUBY_VM_CHECK_INTS_BLOCKING): ditto.

* thread.c (rb_threadptr_execute_interrupts):
  don't process interrupt if it is masked.
  [Bug #6009] [ruby-core:42524]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 10:57:39 +00:00
kosaki 7087153156 split trap interrupt and async interrupt
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37855 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 09:22:01 +00:00
kosaki f150ed1532 * vm_core.h (rb_thread_struct): added 'in_trap' member for marking
running trap handler.
* signal.c (signal_exec): turn on in_trap when running trap.
* thread.c (Init_Thread, thread_create_core): initialize in_trap
  when creating new threads.
* thread.c (thread_join_m): raise ThreadError when running trap
  handler.Bug [#6416][ruby-core:44956]
* test/ruby/test_thread.rb (test_thread_join_in_trap): new test
  for the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 08:05:49 +00:00
kosaki 82b33551a4 * thread.c (thread_create_core): don't use th->thread_id before
initialized.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-24 02:00:10 +00:00
ko1 553931962a * vm_trace.c: add two methods:
(1) TracePoint#return_value which returns return
  value on the :return and :c_return event.
  (2) TracePoint#raised_exception which returns raised exception
  value on the :raise event.
  Eeach methods raise RuntimeError if it is called at unsupported
  event.
  Please review and give us feedback until next preview
  release (Dec/2012) of Ruby 2.0.0.
* insns.def, vm.c, vm_eval.c, vm_insnhelper.c, eval.c, thread.c:
  ditto.
* vm_trace.c, vm_core.h: move definition of rb_trace_arg_t from
  vm_trace.c to vm_core.h.
  Caller fills rb_trace_arg_t and pass the pointer of this variable.
* test/ruby/test_settracefunc.rb: fix tests to test this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-20 09:48:24 +00:00
kosaki b74e1b21db revert r37730
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-20 01:21:19 +00:00
kosaki 57ee812851 * thread.c (rb_thread_s_check_interrupt): removed redundant
GET_THREAD().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-19 11:15:07 +00:00
kosaki 4b25e0ceca * thread.c (rb_threadptr_async_errinfo_active_p): added a small
comment.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-19 11:13:40 +00:00
kosaki 212150c2e1 * thread.c, vm_core.h: big rename th to cur_th when works only
th is current thread.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37730 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-19 11:10:24 +00:00
kosaki 0a2da327f4 * thread.c (rb_thread_blocking_region_end): replaced GET_THREAD()
with ruby_thread_from_native(). We don't have GVL here.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37729 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-19 11:07:53 +00:00
kosaki 7643e4604b * thread.c (rb_threadptr_execute_interrupts) removed.
* thread.c (rb_threadptr_execute_interrupts_common) renamed to
  rb_threadptr_execute_interrupts. I.e. unified
  rb_threadptr_execute_interrupts and rb_threadptr_execute_interrupts_common.
* thread.c (rb_thread_schedule, rb_thread_execute_interrupts) s/_common//.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-19 11:04:39 +00:00
kosaki 6c56dae4b2 * prelude.rb: Moved Mutex#synchronize to
* thread.c (rb_mutex_synchronize_m): here. [Bug #4266]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-19 10:22:53 +00:00
ko1 15d940b8b0 * thread.c: add `Thread#backtrace_locations' method.
This method is similart to `caller_locations' method for
  specific method.
  And fix to accept `level' and `n' parameters for `Thread#backtrace'
  and `Thread#backtrace_locations'.
  `caller' (and `caller_locations') do not return `caller' method
  frame.
  However, `Thread#backtrace' (and `Thread#backtrace_locations')
  return `Thread#backtrace' method frame itself
  if `Thread.current.backtrace' was called.
* vm_backtrace.c: ditto.
* internal.h: ditto.
* test/ruby/test_backtrace.rb: add tests.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-19 06:07:06 +00:00
ko1 9ee34b15e4 * thread.c (rb_thread_call_without_gvl2): change the parameter of
`func' from `int *skip_interrupt' to `VALUE *flags'.
  If (flags & RUBY_CALL_WO_GVL_FLAG_SKIP_CHECK_INTS) is not zero,
  then skip checking interrupt.
  [ruby-core:46547]
* include/ruby/thread.h: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-16 10:34:54 +00:00
naruse 71dcc25fb7 suppress warning: 'val' may be used uninitialized in this function
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-01 19:48:34 +00:00
drbrain 7ae466f134 * thread.c (rb_thread_call_without_gvl2): Note that ubf() may or may
not be called with the GVL.  Hinted that rb_thread_call_with_gvl()
  can be used to access ruby functionality.  [ruby-trunk - #6433]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-31 00:29:27 +00:00
drbrain 5562411c7f * thread.c (rb_thread_call_without_gvl2): Update documentation to
natural English.
* thread.c (rb_thread_call_with_gvl):  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-31 00:07:17 +00:00
tenderlove 2285319b31 * thread.c: added Thread#thread_variable_(get|set),
Thread#thread_variable?, and Thread#thread_variables for operating
  on variables that are local to threads. [ruby-core:47790]

* vm.c: ditto

* test/ruby/test_thread.rb: tests for thread variables.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-29 17:22:36 +00:00
ko1 479d8ce5b5 * thread.c (thread_raise_m): check interrupts after Thread#raise
if a target thread is the current thread because the behavior
  of Thread.current.raise is expected to perform same as
  Kernel.raise (by rubyspec).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-23 13:37:45 +00:00
ko1 a4f79a6ece Revert the last commit because some tests (in btest) fail
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-23 04:52:20 +00:00
ko1 d41ec2a79a * thread.c (rb_threadptr_raise): check interrupts after
Thread#raise because the behavior of Thread.current.raise is
  expected to perform same as Kernel.raise (by rubyspec).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-23 04:33:04 +00:00
ko1 8addee9649 * thread.c (rb_threadptr_interrupt_mask): fix to check interrupt
after interrupt_mask changed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-16 23:03:54 +00:00
zzak 61d460e5e1 * thread.c (rb_thread_aref):
Grammar in Thread documentation.
  Patch by Steve Klabnik [ruby-dev:47799] [Bug #7099]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-06 19:51:40 +00:00
nobu f228a4b209 thread.c: static
* thread.c (patrol_thread): should be static.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-10 08:21:02 +00:00
kosaki 10c14095de * thread.c (rb_mutex_lock): stop multiple threads use
pthread_cond_timedwait() concurrently. [Bug #6278] [ruby-core:44275]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-09 06:27:02 +00:00
nobu ceece4650a vm_insnhelper.c: iclass as klass in cfp
* vm_insnhelper.c (vm_call_method): follow iclasses as klass in cfp
  but not included modules.  [ruby-core:47241] [Bug #6891]
* vm_insnhelper.c (vm_call_bmethod): pass defined_class to follow
  proper ancestors.  [ruby-core:47241] [Bug #6891]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-20 11:36:34 +00:00
ko1 4a4a702e61 * vm_trace.c, vm_core.h: simplify tracing mechanism.
(1) add rb_hook_list_t data structure which includes
  hooks, events (flag) and `need_clean' flag.
  If the last flag is true, then clean the hooks list.
  In other words, deleted hooks are contained by `hooks'.
  Cleanup process should run before traversing the list.
  (2) Change check mechanism
  See EXEC_EVENT_HOOK() in vm_core.h.
  (3) Add `raw' hooks APIs
  Normal hooks are guarded from exception by rb_protect().
  However, this protection is overhead for too simple
  functions which never cause exceptions.  `raw' hooks
  are executed without protection and faster.
  Now, we only provide registration APIs.  All `raw'
  hooks are kicked under protection (same as normal hooks).
* include/ruby/ruby.h: remove internal data definition and
  macros.
* internal.h (ruby_suppress_tracing), vm_trace.c: rename
  ruby_suppress_tracing() to rb_suppress_tracing()
  and remove unused function parameter.
* parse.y: fix to use renamed rb_suppress_tracing().
* thread.c (thread_create_core): no need to set RUBY_VM_VM.
* vm.c (mark_event_hooks): move definition to vm_trace.c.
* vm.c (ruby_vm_event_flags): add a global variable.
  This global variable represents all of Threads and VM's
  event masks (T1#events | T2#events | ... | VM#events).
  You can check the possibility kick trace func or not
  with ruby_vm_event_flags.
  ruby_vm_event_flags is maintained by vm_trace.c.
* cont.c (fiber_switch, rb_cont_call): restore tracing status.
  [Feature #4347]
* test/ruby/test_continuation.rb: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-16 11:41:24 +00:00
ko1 8eb93103e4 * vm_trace.c: separate trace_func related functions from
thread.c.
* thread.c: ditto.
* common.mk: add vm_trace.o.
* inits.c: call Init_vm_trace().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-15 04:39:10 +00:00
nagachika 9cdf55485a * thread.c (thread_create_core): hide th->async_errinfo_mask_stack from
ObjectSpace.each_object. refix of r36539.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-29 16:00:36 +00:00
ktsj afde2e8d05 * thread.c (Init_Thread): does not need to set klass
explicitly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-29 05:28:04 +00:00
nagachika ea637ebaa4 * thread.c (thread_create_core, Init_Thread): hide
th->async_errinfo_queue and th->async_errinfo_mask_stack from
  ObjectSpace.each_object.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-25 16:40:04 +00:00
naruse ee755e2ce9 * thread.c (rb_threadptr_execute_interrupts_common): increase
running_time_us on THREAD_TO_KILL like on THREAD_RUNNABLE.
  This cause not to siwtch from a thread which is to be killed
  on FreeBSD and Mac OS X. see also the test.
  This issue maybe exist for long time but happens after r36430.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-22 15:04:11 +00:00
ko1 f4a8db647a * thread.c (rb_thread_s_control_interrupt,
rb_thread_s_check_interrupt): added for
  Thread.control_intgerrupt and Thread.check_interrupt.
  See details on rdoc.
  I'll make an ticket for this feature.
* test/ruby/test_thread.rb: add a test for Thread.control_intgerrupt.
* thread.c (rb_threadptr_raise): make a new exception object
  even if argc is 0.
* thread.c (rb_thread_kill): kill thread immediately if target thread
  is current thread.
* vm_core.h (RUBY_VM_CHECK_INTS_BLOCKING): added.
  CHECK_INTS while/after blocking operation.
* vm_core.h (RUBY_VM_CHECK_INTS): require rb_thread_t ptr.
* cont.c (fiber_switch): use replaced RUBY_VM_CHECK_INTS().
* eval.c (ruby_cleanup): ditto.
* insns.def: ditto.
* process.c (rb_waitpid): ditto.
* vm_eval.c (vm_call0): ditto.
* vm_insnhelper.c (vm_call_method): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-19 14:19:40 +00:00
nobu 5e7fa03bc0 thread.c: remove deprecated
* thread.c (rb_gc_mark_threads): remove deprecated function.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-19 05:15:51 +00:00
ko1 e9a91d2c95 * thread.c (rb_thread_call_without_gvl2): added.
it can skip last CHECK_INTS.  See document for more details.
  Document about it was updated a bit.
* include/ruby/thread.h (decl. of rb_thread_call_without_gvl2): added.
* thread.c (rb_thread_call_with_gvl): remove "EXPERIMENTAL!"
  warning from a document.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-18 06:47:43 +00:00
ko1 eff4b2b2e1 * thread.c: fix last commit miss.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-18 05:47:48 +00:00
ko1 28144433b2 * thread.c (rb_threadptr_async_errinfo_*): manage async errors queue.
Async events such as an exception throwed by Thread#raise,
  Thread#kill and thread termination (after main thread termination)
  will be queued to th->async_errinfo_queue.
  - clear: clear the queue.
  - enque: enque err object into queue.
  - deque: deque err object from queue.
  - active_p: return 1 if the queue should be checked.
  rb_thread_t#thrown_errinfo was removed.
* vm_core.h: add declarations of rb_threadptr_async_errinfo_*.
  remove rb_thread_t#thrown_errinfo field and
  add rb_thread_t#async_errinfo_queue (queue body: Array),
  rb_thread_t#async_errinfo_queue_checked (flag),
  rb_thread_t#async_errinfo_mask_stack(Array, not used yet).
* vm.c (rb_thread_mark): fix a mark function.
* cont.c (rb_fiber_start): enque an error.
* process.c (after_fork): clear async errinfo queue.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-18 05:46:40 +00:00
nobu c51a826764 rb_thread_call_without_gvl
* include/ruby/thread.h: new header file for thread stuff.
* thread.c (rb_thread_call_without_gvl): export.  [Feature#4328]
  returns void* instead of VALUE.  [Feature #5543]
* thread.c (rb_thread_blocking_region): deprecate.  [ruby-core:46295]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-10 13:57:11 +00:00
nobu 8a995a56c7 thread.c: unsigned
* thread.c (rb_thread_shield_waiting_{inc,dec}): should be unsigned.
  int is large enough since ruby requires it to be 32bit at least.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36331 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-06 03:46:39 +00:00
nobu a2d0ee620f ThreadShield: check waiting count
* thread.c (rb_thread_shield_waiting_{inc,dec}): check waiting count.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-06 03:24:41 +00:00