summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-30 02:53:57 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-30 02:53:57 (GMT)
commit56458959a8bb080a46aee2f5b50a8347f85753d2 (patch)
tree7136ff0d8b007b9a3cad22cfae1134594b9ef40e /thread.c
parent2735af4daf7e94398f0dbe05f2c60334aa503cbe (diff)
thread.c: identical hash
* thread.c (rb_thread_s_handle_interrupt): make identical hash, to compare masking classes just by their IDs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/thread.c b/thread.c
index 8ca3f01..a9642b7 100644
--- a/thread.c
+++ b/thread.c
@@ -1695,12 +1695,19 @@ rb_threadptr_pending_interrupt_active_p(rb_thread_t *th)
}
static int
-handle_interrupt_arg_check_i(VALUE key, VALUE val)
+handle_interrupt_arg_check_i(VALUE key, VALUE val, VALUE args)
{
+ VALUE *maskp = (VALUE *)args;
+
if (val != sym_immediate && val != sym_on_blocking && val != sym_never) {
rb_raise(rb_eArgError, "unknown mask signature");
}
+ if (!*maskp) {
+ *maskp = rb_ident_hash_new();
+ }
+ rb_hash_aset(*maskp, key, val);
+
return ST_CONTINUE;
}
@@ -1822,8 +1829,12 @@ rb_thread_s_handle_interrupt(VALUE self, VALUE mask_arg)
rb_raise(rb_eArgError, "block is needed.");
}
- mask = rb_convert_type(mask_arg, T_HASH, "Hash", "to_hash");
- rb_hash_foreach(mask, handle_interrupt_arg_check_i, 0);
+ mask = 0;
+ mask_arg = rb_convert_type(mask_arg, T_HASH, "Hash", "to_hash");
+ rb_hash_foreach(mask_arg, handle_interrupt_arg_check_i, (VALUE)&mask);
+ if (!mask) {
+ return rb_yield(Qnil);
+ }
rb_ary_push(th->pending_interrupt_mask_stack, mask);
if (!rb_threadptr_pending_interrupt_empty_p(th)) {
th->pending_interrupt_queue_checked = 0;