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
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
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
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
* 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
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
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
(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
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
* 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
* 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
* 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
* 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
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
* 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
[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
* 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
* 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
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
* 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
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
* 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
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
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
* 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
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
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
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
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
* 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
* 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
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
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
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
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
* 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
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
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
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
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
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
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
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
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
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
(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
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
`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
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
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
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
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
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
* 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
(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
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
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
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
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
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
* 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