mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
b16e6a93ca
commit
6116f52f61
2 changed files with 11 additions and 34 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Fri Oct 30 13:36:39 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* 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@ruby-lang.org>
|
Fri Oct 30 13:13:16 2009 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* win32.c (recvmsg, sendmsg, link): shouldn't raise ruby's exceptions
|
* win32.c (recvmsg, sendmsg, link): shouldn't raise ruby's exceptions
|
||||||
|
|
39
thread.c
39
thread.c
|
@ -1028,23 +1028,6 @@ rb_thread_blocking_region_end(struct rb_blocking_region_buffer *region)
|
||||||
RUBY_VM_CHECK_INTS();
|
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.
|
* 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_IO: ubf for IO operation
|
||||||
* * RUBY_UBF_PROCESS: ubf for process operation
|
* * RUBY_UBF_PROCESS: ubf for process operation
|
||||||
*
|
*
|
||||||
* NOTE: You can not execute most of Ruby C API and touch Ruby objects
|
* NOTE: You can not execute most of Ruby C API and touch Ruby
|
||||||
* in `func()' and `ubf()' because current thread doesn't acquire
|
* objects in `func()' and `ubf()', including raising an
|
||||||
* GVL (cause synchronization problem). If you need to do it,
|
* 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.
|
* read source code of C APIs and confirm by yourself.
|
||||||
*
|
*
|
||||||
* NOTE: In short, this API is difficult to use safely. I recommend you
|
* NOTE: In short, this API is difficult to use safely. I recommend you
|
||||||
|
@ -1087,28 +1071,15 @@ rb_thread_blocking_region(
|
||||||
{
|
{
|
||||||
VALUE val;
|
VALUE val;
|
||||||
rb_thread_t *th = GET_THREAD();
|
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) {
|
if (ubf == RUBY_UBF_IO || ubf == RUBY_UBF_PROCESS) {
|
||||||
ubf = ubf_select;
|
ubf = ubf_select;
|
||||||
data2 = th;
|
data2 = th;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PROHIBIT_FUNCTION_CAST
|
|
||||||
BLOCKING_REGION({
|
BLOCKING_REGION({
|
||||||
args.func = func;
|
val = func(data1);
|
||||||
args.data = data1;
|
|
||||||
val = rb_protect(call_blocking_function, (VALUE)&args, &status);
|
|
||||||
}, ubf, data2);
|
}, 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;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue