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

ruby-changes:13773

From: nobu <ko1@a...>
Date: Fri, 30 Oct 2009 13:41:00 +0900 (JST)
Subject: [ruby-changes:13773] Ruby:r25570 (trunk): * thread.c (rb_thread_blocking_region): reverted r25566, and added

nobu	2009-10-30 13:36:40 +0900 (Fri, 30 Oct 2009)

  New Revision: 25570

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

  Log:
    * thread.c (rb_thread_blocking_region): reverted r25566, and added
      description that no exception is allowed inside `func', instead.
      see [ruby-dev:39582]

  Modified files:
    trunk/ChangeLog
    trunk/thread.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 25569)
+++ ChangeLog	(revision 25570)
@@ -1,3 +1,9 @@
+Fri Oct 30 13:36:39 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* thread.c (rb_thread_blocking_region): reverted r25566, and added
+	  description that no exception is allowed inside `func', instead.
+	  see [ruby-dev:39582]
+
 Fri Oct 30 13:13:16 2009  NAKAMURA Usaku  <usa@r...>
 
 	* win32.c (recvmsg, sendmsg, link): shouldn't raise ruby's exceptions
Index: thread.c
===================================================================
--- thread.c	(revision 25569)
+++ thread.c	(revision 25570)
@@ -1028,23 +1028,6 @@
     RUBY_VM_CHECK_INTS();
 }
 
-#ifndef PROHIBIT_FUNCTION_CAST
-#define PROHIBIT_FUNCTION_CAST 0
-#endif
-#if PROHIBIT_FUNCTION_CAST
-struct blocking_function_args {
-    rb_blocking_function_t *func;
-    void *data;
-};
-
-static VALUE
-call_blocking_function(VALUE arg)
-{
-    struct blocking_function_args *blocking = (void *)arg;
-    return (blocking->func)(blocking->data);
-}
-#endif
-
 /*
  * rb_thread_blocking_region - permit concurrent/parallel execution.
  *
@@ -1066,9 +1049,10 @@
  *     * RUBY_UBF_IO: ubf for IO operation
  *     * RUBY_UBF_PROCESS: ubf for process operation
  *
- *   NOTE: You can not execute most of Ruby C API and touch Ruby objects
- *         in `func()' and `ubf()' because current thread doesn't acquire
- *         GVL (cause synchronization problem).  If you need to do it,
+ *   NOTE: You can not execute most of Ruby C API and touch Ruby
+ *         objects in `func()' and `ubf()', including raising an
+ *         exception, because current thread doesn't acquire GVL
+ *         (cause synchronization problem).  If you need to do it,
  *         read source code of C APIs and confirm by yourself.
  *
  *   NOTE: In short, this API is difficult to use safely.  I recommend you
@@ -1087,28 +1071,15 @@
 {
     VALUE val;
     rb_thread_t *th = GET_THREAD();
-    int status;
-#if PROHIBIT_FUNCTION_CAST
-    struct blocking_function_args args;
-#endif
 
     if (ubf == RUBY_UBF_IO || ubf == RUBY_UBF_PROCESS) {
 	ubf = ubf_select;
 	data2 = th;
     }
 
-#if PROHIBIT_FUNCTION_CAST
     BLOCKING_REGION({
-	args.func = func;
-	args.data = data1;
-	val = rb_protect(call_blocking_function, (VALUE)&args, &status);
+	val = func(data1);
     }, ubf, data2);
-#else
-    BLOCKING_REGION({
-	val = rb_protect((VALUE (*)(VALUE))func, (VALUE)data1, &status);
-    }, ubf, data2);
-#endif
-    if (status) rb_jump_tag(status);
 
     return val;
 }

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

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