diff options
| author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-13 06:10:26 +0000 |
|---|---|---|
| committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-13 06:10:26 +0000 |
| commit | 7b15ff44c1a48adc8ac41532a7a7b80e69585d80 (patch) | |
| tree | d385154d3258557de666376f3ffbb2ce6175b677 /thread.c | |
| parent | 98ee4d64f070a484bc9159010bb0fc727f297f7e (diff) | |
merges r23959 from trunk into ruby_1_9_1.
--
* thread.c (rb_threadptr_exec_event_hooks): new function to
execute event hooks, with preserving errinfo. [ruby-core:24118]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@24068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
| -rw-r--r-- | thread.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -3484,6 +3484,32 @@ set_threads_event_flags(int flag) st_foreach(GET_VM()->living_threads, set_threads_event_flags_i, (st_data_t) flag); } +static inline void +exec_event_hooks(const rb_event_hook_t *hook, rb_event_flag_t flag, VALUE self, ID id, VALUE klass) +{ + for (; hook; hook = hook->next) { + if (flag & hook->flag) { + (*hook->func)(flag, hook->data, self, id, klass); + } + } +} + +void +rb_threadptr_exec_event_hooks(rb_thread_t *th, rb_event_flag_t flag, VALUE self, ID id, VALUE klass) +{ + const VALUE errinfo = th->errinfo; + const rb_event_flag_t wait_event = th->event_flags; + + if (self == rb_mRubyVMFrozenCore) return; + if (wait_event & flag) { + exec_event_hooks(th->event_hooks, flag, self, id, klass); + } + if (wait_event & RUBY_EVENT_VM) { + exec_event_hooks(th->vm->event_hooks, flag, self, id, klass); + } + th->errinfo = errinfo; +} + void rb_add_event_hook(rb_event_hook_func_t func, rb_event_flag_t events, VALUE data) { |
