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

ruby-changes:38205

From: nobu <ko1@a...>
Date: Mon, 13 Apr 2015 16:54:43 +0900 (JST)
Subject: [ruby-changes:38205] nobu:r50286 (trunk): variable.c: ensure

nobu	2015-04-13 16:54:39 +0900 (Mon, 13 Apr 2015)

  New Revision: 50286

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

  Log:
    variable.c: ensure
    
    * variable.c (rb_autoload_load): prefer rb_ensure than rb_protect
      for rollback.

  Modified files:
    trunk/variable.c
Index: variable.c
===================================================================
--- variable.c	(revision 50285)
+++ variable.c	(revision 50286)
@@ -1804,13 +1804,22 @@ autoload_require(VALUE arg) https://github.com/ruby/ruby/blob/trunk/variable.c#L1804
     return rb_require_safe(ele->feature, ele->safe_level);
 }
 
+static VALUE
+autoload_reset(VALUE arg)
+{
+    struct autoload_data_i *ele = (struct autoload_data_i *)arg;
+    if (ele->thread == rb_thread_current()) {
+	ele->thread = Qnil;
+    }
+    return 0;			/* ignored */
+}
+
 VALUE
 rb_autoload_load(VALUE mod, ID id)
 {
     VALUE load, result;
     const char *loading = 0, *src;
     struct autoload_data_i *ele;
-    int state = 0;
 
     if (!autoload_defined_p(mod, id)) return Qfalse;
     load = check_autoload_required(mod, id, &loading);
@@ -1826,11 +1835,7 @@ rb_autoload_load(VALUE mod, ID id) https://github.com/ruby/ruby/blob/trunk/variable.c#L1835
 	ele->thread = rb_thread_current();
     }
     /* autoload_data_i can be deleted by another thread while require */
-    result = rb_protect(autoload_require, (VALUE)ele, &state);
-    if (ele->thread == rb_thread_current()) {
-	ele->thread = Qnil;
-    }
-    if (state) rb_jump_tag(state);
+    result = rb_ensure(autoload_require, (VALUE)ele, autoload_reset, (VALUE)ele);
 
     if (RTEST(result)) {
 	/* At the last, move a value defined in autoload to constant table */

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

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