summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-26 21:30:44 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-26 21:30:44 +0000
commite2793a908e23dd1dde5eaf553c5bb7ed5e8533c9 (patch)
tree2a84a99f5145481d7781121cb7836b82881953f9 /test
parent767debf92e7f21f48631ebb4764ba16cfaf1d7f0 (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 'test')
-rw-r--r--test/-ext-/postponed_job/test_postponed_job.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/-ext-/postponed_job/test_postponed_job.rb b/test/-ext-/postponed_job/test_postponed_job.rb
new file mode 100644
index 0000000000..a554936b3d
--- /dev/null
+++ b/test/-ext-/postponed_job/test_postponed_job.rb
@@ -0,0 +1,25 @@
+require 'test/unit'
+require 'thread'
+require '-test-/postponed_job'
+
+module Bug
+ def self.postponed_job_call_direct_wrapper(*args)
+ postponed_job_call_direct(*arg)
+ end
+
+ def self.postponed_job_register_wrapper(*args)
+ postponed_job_register(*args)
+ end
+end
+
+class TestTask < Test::Unit::TestCase
+ def test_register
+ direct, registered = [], []
+
+ Bug.postponed_job_call_direct_wrapper(direct)
+ Bug.postponed_job_register_wrapper(registered)
+
+ assert_match /postponed_job_call_direct_wrapper/, direct.join
+ assert_not_match /postponed_job_register_wrapper/, registered.join
+ end
+end \ No newline at end of file