1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* vm_trace.c (rb_postponed_job_register_one): fix iteration bug.

* ext/-test-/postponed_job/postponed_job.c,
  test/-ext-/postponed_job/test_postponed_job.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2013-05-27 17:08:25 +00:00
parent f79ddbebe3
commit c180e0d880
4 changed files with 30 additions and 0 deletions

View file

@ -17,6 +17,24 @@ pjob_register(VALUE self, VALUE obj)
return self;
}
static void
pjob_one_callback(void *data)
{
VALUE ary = (VALUE)data;
Check_Type(ary, T_ARRAY);
rb_ary_push(ary, INT2FIX(1));
}
static VALUE
pjob_register_one(VALUE self, VALUE obj)
{
rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
return self;
}
static VALUE
pjob_call_direct(VALUE self, VALUE obj)
{
@ -29,6 +47,7 @@ Init_postponed_job(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_register_one", pjob_register_one, 1);
rb_define_module_function(mBug, "postponed_job_call_direct", pjob_call_direct, 1);
}