diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-26 21:30:44 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-26 21:30:44 +0000 |
commit | e2793a908e23dd1dde5eaf553c5bb7ed5e8533c9 (patch) | |
tree | 2a84a99f5145481d7781121cb7836b82881953f9 /vm_core.h | |
parent | 767debf92e7f21f48631ebb4764ba16cfaf1d7f0 (diff) |
* 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
Diffstat (limited to 'vm_core.h')
-rw-r--r-- | vm_core.h | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -379,6 +379,8 @@ typedef struct rb_vm_struct { /* hook */ rb_hook_list_t event_hooks; + struct rb_postponed_job_struct *postponed_job; + int src_encoding_index; VALUE verbose, debug, progname; @@ -902,15 +904,15 @@ GET_THREAD(void) #endif enum { - TIMER_INTERRUPT_MASK = 0x01, - PENDING_INTERRUPT_MASK = 0x02, - FINALIZER_INTERRUPT_MASK = 0x04, - TRAP_INTERRUPT_MASK = 0x08 + TIMER_INTERRUPT_MASK = 0x01, + PENDING_INTERRUPT_MASK = 0x02, + POSTPONED_JOB_INTERRUPT_MASK = 0x04, + TRAP_INTERRUPT_MASK = 0x08 }; #define RUBY_VM_SET_TIMER_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, TIMER_INTERRUPT_MASK) #define RUBY_VM_SET_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, PENDING_INTERRUPT_MASK) -#define RUBY_VM_SET_FINALIZER_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, FINALIZER_INTERRUPT_MASK) +#define RUBY_VM_SET_POSTPONED_JOB_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, POSTPONED_JOB_INTERRUPT_MASK) #define RUBY_VM_SET_TRAP_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, TRAP_INTERRUPT_MASK) #define RUBY_VM_INTERRUPTED(th) ((th)->interrupt_flag & ~(th)->interrupt_mask & (PENDING_INTERRUPT_MASK|TRAP_INTERRUPT_MASK)) #define RUBY_VM_INTERRUPTED_ANY(th) ((th)->interrupt_flag & ~(th)->interrupt_mask) @@ -1000,6 +1002,8 @@ extern VALUE rb_get_coverages(void); extern void rb_set_coverages(VALUE); extern void rb_reset_coverages(void); +void rb_postponed_job_flush(rb_vm_t *vm); + RUBY_SYMBOL_EXPORT_END #endif /* RUBY_VM_CORE_H */ |