summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-30 04:36:40 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-30 04:36:40 +0000
commit6116f52f6132ed65c003ed42726bba1298aab8f2 (patch)
treea5b5d7d1efd22a963daa954bfeaf36ee32c071ab /thread.c
parentb16e6a93ca4746d301c7f66b5407c05e44f1cc91 (diff)
* thread.c (rb_thread_blocking_region): reverted r25566, and added
description that no exception is allowed inside `func', instead. see [ruby-dev:39582] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c39
1 files changed, 5 insertions, 34 deletions
diff --git a/thread.c b/thread.c
index 4771c5d0db..32e54996bf 100644
--- a/thread.c
+++ b/thread.c
@@ -1028,23 +1028,6 @@ rb_thread_blocking_region_end(struct rb_blocking_region_buffer *region)
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 @@ call_blocking_function(VALUE arg)
* * 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 @@ rb_thread_blocking_region(
{
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);
- }, ubf, data2);
-#else
BLOCKING_REGION({
- val = rb_protect((VALUE (*)(VALUE))func, (VALUE)data1, &status);
+ val = func(data1);
}, ubf, data2);
-#endif
- if (status) rb_jump_tag(status);
return val;
}