summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-05 19:37:49 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-05 19:37:49 +0000
commitfe6b2e20e9f17ed2c2900aa72994e075ffdc7124 (patch)
tree13f2b2f26be57d3cd6f25b0e6483484d9dc22d1e /thread.c
parentdef63c3466939161f2459f6489815b444bbde8a3 (diff)
* thread.c (rb_uninterruptible): helper function for providing
temporary async_interrupt_timing(Object => :defer) * io.c (rb_f_p): use rb_uninterruptible. * io.c (rb_f_p_internal): helper function for rb_f_p(). * io.c (struct rb_f_p_arg): new struct for rb_f_p_internal. * test/ruby/test_thread.rb (test_async_interrupt_and_p): test for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/thread.c b/thread.c
index 8fd4580ab2..4ea4c58f5d 100644
--- a/thread.c
+++ b/thread.c
@@ -5048,3 +5048,15 @@ rb_reset_coverages(void)
GET_VM()->coverages = Qfalse;
rb_remove_event_hook(update_coverage);
}
+
+VALUE
+rb_uninterruptible(VALUE (*b_proc)(ANYARGS), VALUE data)
+{
+ VALUE interrupt_mask = rb_hash_new();
+ rb_thread_t *cur_th = GET_THREAD();
+
+ rb_hash_aset(interrupt_mask, rb_cObject, ID2SYM(rb_intern("defer")));
+ rb_ary_push(cur_th->async_errinfo_mask_stack, interrupt_mask);
+
+ return rb_ensure(b_proc, data, rb_ary_pop, cur_th->async_errinfo_mask_stack);
+}