add flags
to rb_postponed_job_preregister
for future extensions.
This commit is contained in:
parent
f8effa209a
commit
c4c39082af
@ -137,7 +137,7 @@ static VALUE
|
|||||||
pjob_preregister_and_call_with_sleep(VALUE self, VALUE obj)
|
pjob_preregister_and_call_with_sleep(VALUE self, VALUE obj)
|
||||||
{
|
{
|
||||||
counter = 0;
|
counter = 0;
|
||||||
rb_postponed_job_handle_t h = rb_postponed_job_preregister(pjob_preregistered_callback, (void *)obj);
|
rb_postponed_job_handle_t h = rb_postponed_job_preregister(0, pjob_preregistered_callback, (void *)obj);
|
||||||
counter++;
|
counter++;
|
||||||
rb_postponed_job_trigger(h);
|
rb_postponed_job_trigger(h);
|
||||||
rb_thread_sleep(0);
|
rb_thread_sleep(0);
|
||||||
@ -154,7 +154,7 @@ static VALUE
|
|||||||
pjob_preregister_and_call_without_sleep(VALUE self, VALUE obj)
|
pjob_preregister_and_call_without_sleep(VALUE self, VALUE obj)
|
||||||
{
|
{
|
||||||
counter = 0;
|
counter = 0;
|
||||||
rb_postponed_job_handle_t h = rb_postponed_job_preregister(pjob_preregistered_callback, (void *)obj);
|
rb_postponed_job_handle_t h = rb_postponed_job_preregister(0, pjob_preregistered_callback, (void *)obj);
|
||||||
counter = 3;
|
counter = 3;
|
||||||
rb_postponed_job_trigger(h);
|
rb_postponed_job_trigger(h);
|
||||||
rb_postponed_job_trigger(h);
|
rb_postponed_job_trigger(h);
|
||||||
@ -165,9 +165,9 @@ pjob_preregister_and_call_without_sleep(VALUE self, VALUE obj)
|
|||||||
static VALUE
|
static VALUE
|
||||||
pjob_preregister_multiple_times(VALUE self)
|
pjob_preregister_multiple_times(VALUE self)
|
||||||
{
|
{
|
||||||
int r1 = rb_postponed_job_preregister(pjob_noop_callback, NULL);
|
int r1 = rb_postponed_job_preregister(0, pjob_noop_callback, NULL);
|
||||||
int r2 = rb_postponed_job_preregister(pjob_noop_callback, NULL);
|
int r2 = rb_postponed_job_preregister(0, pjob_noop_callback, NULL);
|
||||||
int r3 = rb_postponed_job_preregister(pjob_noop_callback, NULL);
|
int r3 = rb_postponed_job_preregister(0, pjob_noop_callback, NULL);
|
||||||
VALUE ary = rb_ary_new();
|
VALUE ary = rb_ary_new();
|
||||||
rb_ary_push(ary, INT2FIX(r1));
|
rb_ary_push(ary, INT2FIX(r1));
|
||||||
rb_ary_push(ary, INT2FIX(r2));
|
rb_ary_push(ary, INT2FIX(r2));
|
||||||
|
@ -106,7 +106,7 @@ Init_gc_hook(VALUE module)
|
|||||||
rb_define_module_function(module, "after_gc_exit_hook=", start_after_gc_exit, 1);
|
rb_define_module_function(module, "after_gc_exit_hook=", start_after_gc_exit, 1);
|
||||||
rb_gc_register_address(&gc_start_proc);
|
rb_gc_register_address(&gc_start_proc);
|
||||||
rb_gc_register_address(&gc_end_proc);
|
rb_gc_register_address(&gc_end_proc);
|
||||||
invoking_proc_pjob = rb_postponed_job_preregister(invoke_proc, NULL);
|
invoking_proc_pjob = rb_postponed_job_preregister(0, invoke_proc, NULL);
|
||||||
if (invoking_proc_pjob == POSTPONED_JOB_HANDLE_INVALID) {
|
if (invoking_proc_pjob == POSTPONED_JOB_HANDLE_INVALID) {
|
||||||
rb_raise(rb_eStandardError, "could not preregister invoke_proc");
|
rb_raise(rb_eStandardError, "could not preregister invoke_proc");
|
||||||
}
|
}
|
||||||
|
2
gc.c
2
gc.c
@ -1909,7 +1909,7 @@ rb_objspace_alloc(void)
|
|||||||
rb_objspace_t *objspace = calloc1(sizeof(rb_objspace_t));
|
rb_objspace_t *objspace = calloc1(sizeof(rb_objspace_t));
|
||||||
objspace->flags.measure_gc = 1;
|
objspace->flags.measure_gc = 1;
|
||||||
malloc_limit = gc_params.malloc_limit_min;
|
malloc_limit = gc_params.malloc_limit_min;
|
||||||
objspace->finalize_deferred_pjob = rb_postponed_job_preregister(gc_finalize_deferred, objspace);
|
objspace->finalize_deferred_pjob = rb_postponed_job_preregister(0, gc_finalize_deferred, objspace);
|
||||||
if (objspace->finalize_deferred_pjob == POSTPONED_JOB_HANDLE_INVALID) {
|
if (objspace->finalize_deferred_pjob == POSTPONED_JOB_HANDLE_INVALID) {
|
||||||
rb_bug("Could not preregister postponed job for GC");
|
rb_bug("Could not preregister postponed job for GC");
|
||||||
}
|
}
|
||||||
|
@ -686,6 +686,7 @@ typedef unsigned int rb_postponed_job_handle_t;
|
|||||||
* version might require that this method be called under the GVL; thus, programs which
|
* version might require that this method be called under the GVL; thus, programs which
|
||||||
* aim to be forward-compatible should call this method whilst holding the GVL.
|
* aim to be forward-compatible should call this method whilst holding the GVL.
|
||||||
*
|
*
|
||||||
|
* @param[in] flags Unused and ignored
|
||||||
* @param[in] func The function to be pre-registered
|
* @param[in] func The function to be pre-registered
|
||||||
* @param[in] data The data to be pre-registered
|
* @param[in] data The data to be pre-registered
|
||||||
* @retval POSTPONED_JOB_HANDLE_INVALID The job table is full; this registration
|
* @retval POSTPONED_JOB_HANDLE_INVALID The job table is full; this registration
|
||||||
@ -693,7 +694,7 @@ typedef unsigned int rb_postponed_job_handle_t;
|
|||||||
* the lifetime of the program.
|
* the lifetime of the program.
|
||||||
* @retval otherwise A handle which can be passed to `rb_postponed_job_trigger`
|
* @retval otherwise A handle which can be passed to `rb_postponed_job_trigger`
|
||||||
*/
|
*/
|
||||||
rb_postponed_job_handle_t rb_postponed_job_preregister(rb_postponed_job_func_t func, void *data);
|
rb_postponed_job_handle_t rb_postponed_job_preregister(unsigned int flags, rb_postponed_job_func_t func, void *data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggers a pre-registered job registered with rb_postponed_job_preregister,
|
* Triggers a pre-registered job registered with rb_postponed_job_preregister,
|
||||||
|
2
rjit.c
2
rjit.c
@ -432,7 +432,7 @@ rb_rjit_init(const struct rb_rjit_options *opts)
|
|||||||
rb_rjit_enabled = false;
|
rb_rjit_enabled = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rjit_iseq_update_references_pjob = rb_postponed_job_preregister(rjit_iseq_update_references, NULL);
|
rjit_iseq_update_references_pjob = rb_postponed_job_preregister(0, rjit_iseq_update_references, NULL);
|
||||||
if (rjit_iseq_update_references_pjob == POSTPONED_JOB_HANDLE_INVALID) {
|
if (rjit_iseq_update_references_pjob == POSTPONED_JOB_HANDLE_INVALID) {
|
||||||
rb_bug("Could not preregister postponed job for RJIT");
|
rb_bug("Could not preregister postponed job for RJIT");
|
||||||
}
|
}
|
||||||
|
@ -1741,7 +1741,7 @@ rb_vm_memsize_postponed_job_queue(void)
|
|||||||
|
|
||||||
|
|
||||||
rb_postponed_job_handle_t
|
rb_postponed_job_handle_t
|
||||||
rb_postponed_job_preregister(rb_postponed_job_func_t func, void *data)
|
rb_postponed_job_preregister(unsigned int flags, rb_postponed_job_func_t func, void *data)
|
||||||
{
|
{
|
||||||
/* The doc comments say that this function should be called under the GVL, because
|
/* The doc comments say that this function should be called under the GVL, because
|
||||||
* that is actually required to get the guarantee that "if a given (func, data) pair
|
* that is actually required to get the guarantee that "if a given (func, data) pair
|
||||||
@ -1789,7 +1789,7 @@ pjob_register_legacy_impl(unsigned int flags, rb_postponed_job_func_t func, void
|
|||||||
{
|
{
|
||||||
/* We _know_ calling preregister from a signal handler like this is racy; what is
|
/* We _know_ calling preregister from a signal handler like this is racy; what is
|
||||||
* and is not promised is very exhaustively documented in debug.h */
|
* and is not promised is very exhaustively documented in debug.h */
|
||||||
rb_postponed_job_handle_t h = rb_postponed_job_preregister(func, data);
|
rb_postponed_job_handle_t h = rb_postponed_job_preregister(0, func, data);
|
||||||
if (h == POSTPONED_JOB_HANDLE_INVALID) {
|
if (h == POSTPONED_JOB_HANDLE_INVALID) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user