1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* thread.c (rb_thread_call_without_gvl2): change the parameter of

`func' from `int *skip_interrupt' to `VALUE *flags'.
  If (flags & RUBY_CALL_WO_GVL_FLAG_SKIP_CHECK_INTS) is not zero,
  then skip checking interrupt.
  [ruby-core:46547]
* include/ruby/thread.h: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2012-11-16 10:34:54 +00:00
parent 6e0375e3e2
commit 9ee34b15e4
3 changed files with 21 additions and 10 deletions

View file

@ -1,3 +1,13 @@
Fri Nov 16 19:24:10 2012 Koichi Sasada <ko1@atdot.net>
* thread.c (rb_thread_call_without_gvl2): change the parameter of
`func' from `int *skip_interrupt' to `VALUE *flags'.
If (flags & RUBY_CALL_WO_GVL_FLAG_SKIP_CHECK_INTS) is not zero,
then skip checking interrupt.
[ruby-core:46547]
* include/ruby/thread.h: ditto.
Fri Nov 16 18:59:05 2012 NARUSE, Yui <naruse@ruby-lang.org>
* Makefile.in (no-dtrace-probes.h): dmyprobes.h is in srcdir.

View file

@ -28,9 +28,10 @@ extern "C" {
void *rb_thread_call_with_gvl(void *(*func)(void *), void *data1);
void *rb_thread_call_without_gvl(void *(*func)(void *), void *data1,
rb_unblock_function_t *ubf, void *data2);
void *rb_thread_call_without_gvl2(void *(*func)(void *, int *), void *data1,
void *rb_thread_call_without_gvl2(void *(*func)(void *, VALUE *), void *data1,
rb_unblock_function_t *ubf, void *data2);
#define RUBY_CALL_WO_GVL_FLAG_SKIP_CHECK_INTS 0x01
#if defined __GNUC__ && __GNUC__ >= 4
#pragma GCC visibility pop

View file

@ -1094,9 +1094,9 @@ rb_thread_blocking_region_end(struct rb_blocking_region_buffer *region)
*
* rb_thread_call_without_gvl2() does:
* (1) release GVL.
* (2) call func with data1 and a pointer to the skip_interrupt flag.
* (2) call func with data1 and a pointer to the flags.
* (3) acquire GVL.
* (4) Check interrupts if skip_interrupt flag is not set.
* (4) Check interrupts if (flags & RUBY_CALL_WO_GVL_FLAG_SKIP_CHECK_INTS) is 0.
*
* If another thread interrupts this thread (Thread#kill, signal delivery,
* VM-shutdown request, and so on), `ubf()' is called (`ubf()' means
@ -1133,12 +1133,12 @@ rb_thread_blocking_region_end(struct rb_blocking_region_buffer *region)
* because it causes irrevocable side-effect, the read data will vanish. To
* avoid such problem, the `read_func()' should be:
*
* read_func(void *data, int *skip_check_flag) {
* read_func(void *data, VALUE *flags) {
* // (a) before read
* read(buffer); // (b) reading
* // (c) after read
* if (read is complete) {
* *skip_check_flag = 1;
* *flags |= RUBY_CALL_WO_GVL_FLAG_SKIP_CHECK_INTS;
* }
* }
*
@ -1164,13 +1164,13 @@ rb_thread_blocking_region_end(struct rb_blocking_region_buffer *region)
* they will work without GVL, and may acquire GVL when GC is needed.
*/
void *
rb_thread_call_without_gvl2(void *(*func)(void *data, int *skip_checkints), void *data1,
rb_thread_call_without_gvl2(void *(*func)(void *data, VALUE *flags), void *data1,
rb_unblock_function_t *ubf, void *data2)
{
void *val;
rb_thread_t *th = GET_THREAD();
int saved_errno = 0;
int skip_checkints = 0;
VALUE flags = 0;
th->waiting_fd = -1;
if (ubf == RUBY_UBF_IO || ubf == RUBY_UBF_PROCESS) {
@ -1179,11 +1179,11 @@ rb_thread_call_without_gvl2(void *(*func)(void *data, int *skip_checkints), void
}
BLOCKING_REGION({
val = func(data1, &skip_checkints);
val = func(data1, &flags);
saved_errno = errno;
}, ubf, data2);
if (!skip_checkints) {
if ((flags & RUBY_CALL_WO_GVL_FLAG_SKIP_CHECK_INTS) == 0) {
RUBY_VM_CHECK_INTS_BLOCKING(th);
}
@ -1198,7 +1198,7 @@ struct without_gvl_wrapper_arg {
};
static void *
without_gvl_wrapper(void *data, int *skip_checkints)
without_gvl_wrapper(void *data, VALUE *flags)
{
struct without_gvl_wrapper_arg *arg = (struct without_gvl_wrapper_arg*)data;
return arg->func(arg->data);