diff options
Diffstat (limited to 'ext/-test-/postponed_job')
-rw-r--r-- | ext/-test-/postponed_job/extconf.rb | 1 | ||||
-rw-r--r-- | ext/-test-/postponed_job/postponed_job.c | 32 |
2 files changed, 33 insertions, 0 deletions
diff --git a/ext/-test-/postponed_job/extconf.rb b/ext/-test-/postponed_job/extconf.rb new file mode 100644 index 0000000000..aa29b593f4 --- /dev/null +++ b/ext/-test-/postponed_job/extconf.rb @@ -0,0 +1 @@ +create_makefile('-test-/postponed_job') diff --git a/ext/-test-/postponed_job/postponed_job.c b/ext/-test-/postponed_job/postponed_job.c new file mode 100644 index 0000000000..a5bb8892b5 --- /dev/null +++ b/ext/-test-/postponed_job/postponed_job.c @@ -0,0 +1,32 @@ +#include "ruby.h" +#include "ruby/debug.h" + +static void +pjob_callback(void *data) +{ + VALUE ary = (VALUE)data; + Check_Type(ary, T_ARRAY); + + rb_ary_replace(ary, rb_funcall(Qnil, rb_intern("caller"), 0)); +} + +static VALUE +pjob_register(VALUE self, VALUE obj) +{ + rb_postponed_job_register(0, pjob_callback, (void *)obj); +} + +static VALUE +pjob_call_direct(VALUE self, VALUE obj) +{ + pjob_callback((void *)obj); +} + +void +Init_task(VALUE self) +{ + VALUE mBug = rb_define_module("Bug"); + rb_define_module_function(mBug, "postponed_job_register", pjob_register, 1); + rb_define_module_function(mBug, "postponed_job_call_direct", pjob_call_direct, 1); +} + |