[前][次][番号順一覧][スレッド一覧]

ruby-changes:39360

From: nobu <ko1@a...>
Date: Thu, 30 Jul 2015 11:54:05 +0900 (JST)
Subject: [ruby-changes:39360] nobu:r51441 (trunk): thread.c: identical hash

nobu	2015-07-30 11:53:57 +0900 (Thu, 30 Jul 2015)

  New Revision: 51441

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51441

  Log:
    thread.c: identical hash
    
    * thread.c (rb_thread_s_handle_interrupt): make identical hash,
      to compare masking classes just by their IDs.

  Modified files:
    trunk/ChangeLog
    trunk/thread.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51440)
+++ ChangeLog	(revision 51441)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Jul 30 11:53:54 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* thread.c (rb_thread_s_handle_interrupt): make identical hash,
+	  to compare masking classes just by their IDs.
+
 Thu Jul 30 11:52:55 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* load.c (rb_load_internal0): stop separating exits at loading
Index: thread.c
===================================================================
--- thread.c	(revision 51440)
+++ thread.c	(revision 51441)
@@ -1695,12 +1695,19 @@ rb_threadptr_pending_interrupt_active_p( https://github.com/ruby/ruby/blob/trunk/thread.c#L1695
 }
 
 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, https://github.com/ruby/ruby/blob/trunk/thread.c#L1829
 	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;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]