* include/ruby/thread.h: new header file for thread stuff.
* thread.c (rb_thread_call_without_gvl): export.  [Feature#4328]
  returns void* instead of VALUE.  [Feature #5543]
* thread.c (rb_thread_blocking_region): deprecate.  [ruby-core:46295]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-07-10 13:57:11 +00:00
Родитель 1a853390ee
Коммит c51a826764
21 изменённых файлов: 134 добавлений и 80 удалений

Просмотреть файл

@ -1,3 +1,12 @@
Tue Jul 10 22:57:03 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* include/ruby/thread.h: new header file for thread stuff.
* thread.c (rb_thread_call_without_gvl): export. [Feature#4328]
returns void* instead of VALUE. [Feature #5543]
* thread.c (rb_thread_blocking_region): deprecate. [ruby-core:46295]
Tue Jul 10 10:48:59 2012 NAKAMURA Usaku <usa@ruby-lang.org>
* include/ruby/win32.h (NT, NtInitialize): removed unused old macros.

Просмотреть файл

@ -10,6 +10,7 @@
**********************************************************************/
#include "ruby/ruby.h"
#include "ruby/thread.h"
#include "ruby/util.h"
#include "internal.h"
@ -2591,7 +2592,7 @@ struct big_div_struct {
VALUE stop;
};
static VALUE
static void *
bigdivrem1(void *ptr)
{
struct big_div_struct *bds = (struct big_div_struct*)ptr;
@ -2605,7 +2606,7 @@ bigdivrem1(void *ptr)
j = nx==ny?nx+1:nx;
for (nyzero = 0; !yds[nyzero]; nyzero++);
do {
if (bds->stop) return Qnil;
if (bds->stop) return 0;
if (zds[j] == yds[ny-1]) q = (BDIGIT)BIGRAD-1;
else q = (BDIGIT)((BIGUP(zds[j]) + zds[j-1])/yds[ny-1]);
if (q) {
@ -2633,7 +2634,7 @@ bigdivrem1(void *ptr)
}
zds[j] = q;
} while (--j >= ny);
return Qnil;
return 0;
}
static void
@ -2725,7 +2726,7 @@ bigdivrem(VALUE x, VALUE y, volatile VALUE *divp, volatile VALUE *modp)
bds.yds = yds;
bds.stop = Qfalse;
if (nx > 10000 || ny > 10000) {
rb_thread_blocking_region(bigdivrem1, &bds, rb_big_stop, &bds.stop);
rb_thread_call_without_gvl(bigdivrem1, &bds, rb_big_stop, &bds.stop);
}
else {
bigdivrem1(&bds);

Просмотреть файл

@ -616,7 +616,7 @@ addr2line.$(OBJEXT): {$(VPATH)}addr2line.c {$(VPATH)}addr2line.h {$(VPATH)}confi
array.$(OBJEXT): {$(VPATH)}array.c $(RUBY_H_INCLUDES) {$(VPATH)}util.h \
$(ENCODING_H_INCLUDES) {$(VPATH)}internal.h
bignum.$(OBJEXT): {$(VPATH)}bignum.c $(RUBY_H_INCLUDES) {$(VPATH)}util.h \
{$(VPATH)}internal.h
{$(VPATH)}thread.h {$(VPATH)}internal.h
class.$(OBJEXT): {$(VPATH)}class.c $(RUBY_H_INCLUDES) \
$(VM_CORE_H_INCLUDES) {$(VPATH)}debug.h {$(VPATH)}internal.h \
{$(VPATH)}constant.h
@ -658,13 +658,15 @@ file.$(OBJEXT): {$(VPATH)}file.c $(RUBY_H_INCLUDES) {$(VPATH)}io.h \
gc.$(OBJEXT): {$(VPATH)}gc.c $(RUBY_H_INCLUDES) {$(VPATH)}re.h \
{$(VPATH)}regex.h $(ENCODING_H_INCLUDES) $(VM_CORE_H_INCLUDES) \
{$(VPATH)}gc.h {$(VPATH)}io.h {$(VPATH)}eval_intern.h {$(VPATH)}util.h \
{$(VPATH)}debug.h {$(VPATH)}internal.h {$(VPATH)}constant.h
{$(VPATH)}debug.h {$(VPATH)}internal.h {$(VPATH)}constant.h \
{$(VPATH)}thread.h
hash.$(OBJEXT): {$(VPATH)}hash.c $(RUBY_H_INCLUDES) {$(VPATH)}util.h \
$(ENCODING_H_INCLUDES)
inits.$(OBJEXT): {$(VPATH)}inits.c $(RUBY_H_INCLUDES) \
{$(VPATH)}internal.h
io.$(OBJEXT): {$(VPATH)}io.c $(RUBY_H_INCLUDES) {$(VPATH)}io.h \
{$(VPATH)}util.h $(ENCODING_H_INCLUDES) {$(VPATH)}dln.h {$(VPATH)}internal.h
{$(VPATH)}util.h $(ENCODING_H_INCLUDES) {$(VPATH)}dln.h \
{$(VPATH)}internal.h {$(VPATH)}thread.h
main.$(OBJEXT): {$(VPATH)}main.c $(RUBY_H_INCLUDES) {$(VPATH)}debug.h \
{$(VPATH)}node.h
marshal.$(OBJEXT): {$(VPATH)}marshal.c $(RUBY_H_INCLUDES) {$(VPATH)}io.h \
@ -690,7 +692,8 @@ proc.$(OBJEXT): {$(VPATH)}proc.c {$(VPATH)}eval_intern.h \
{$(VPATH)}debug.h {$(VPATH)}internal.h {$(VPATH)}iseq.h
process.$(OBJEXT): {$(VPATH)}process.c $(RUBY_H_INCLUDES) \
{$(VPATH)}util.h {$(VPATH)}io.h $(ENCODING_H_INCLUDES) {$(VPATH)}dln.h \
$(VM_CORE_H_INCLUDES) {$(VPATH)}debug.h {$(VPATH)}internal.h
$(VM_CORE_H_INCLUDES) {$(VPATH)}debug.h {$(VPATH)}internal.h \
{$(VPATH)}thread.h
random.$(OBJEXT): {$(VPATH)}random.c $(RUBY_H_INCLUDES)
range.$(OBJEXT): {$(VPATH)}range.c $(RUBY_H_INCLUDES) \
$(ENCODING_H_INCLUDES) {$(VPATH)}internal.h
@ -730,7 +733,7 @@ struct.$(OBJEXT): {$(VPATH)}struct.c $(RUBY_H_INCLUDES) {$(VPATH)}internal.h
thread.$(OBJEXT): {$(VPATH)}thread.c {$(VPATH)}eval_intern.h \
$(RUBY_H_INCLUDES) {$(VPATH)}gc.h $(VM_CORE_H_INCLUDES) \
{$(VPATH)}debug.h {$(VPATH)}thread_$(THREAD_MODEL).c $(ENCODING_H_INCLUDES) \
{$(VPATH)}internal.h {$(VPATH)}io.h
{$(VPATH)}internal.h {$(VPATH)}io.h {$(VPATH)}thread.h
transcode.$(OBJEXT): {$(VPATH)}transcode.c $(RUBY_H_INCLUDES) \
$(ENCODING_H_INCLUDES) {$(VPATH)}transcode_data.h {$(VPATH)}internal.h
cont.$(OBJEXT): {$(VPATH)}cont.c $(RUBY_H_INCLUDES) \

Просмотреть файл

@ -18,6 +18,7 @@
#include "ruby.h"
#include "ruby/io.h"
#include "ruby/thread.h"
#if defined(HAVE_NCURSES_H)
# include <ncurses.h>
@ -634,12 +635,12 @@ curses_addstr(VALUE obj, VALUE str)
return Qnil;
}
static VALUE
static void *
getch_func(void *arg)
{
int *ip = (int *)arg;
*ip = getch();
return Qnil;
return 0;
}
/*
@ -656,7 +657,7 @@ curses_getch(VALUE obj)
int c;
curses_stdscr();
rb_thread_blocking_region(getch_func, (void *)&c, RUBY_UBF_IO, 0);
rb_thread_call_without_gvl(getch_func, &c, RUBY_UBF_IO, 0);
if (c == EOF) return Qnil;
if (rb_isprint(c)) {
char ch = (char)c;
@ -669,7 +670,7 @@ curses_getch(VALUE obj)
/* This should be big enough.. I hope */
#define GETSTR_BUF_SIZE 1024
static VALUE
static void *
getstr_func(void *arg)
{
char *rtn = (char *)arg;
@ -678,7 +679,7 @@ getstr_func(void *arg)
#else
getstr(rtn);
#endif
return Qnil;
return 0;
}
/*
@ -693,7 +694,7 @@ curses_getstr(VALUE obj)
char rtn[GETSTR_BUF_SIZE];
curses_stdscr();
rb_thread_blocking_region(getstr_func, (void *)rtn, RUBY_UBF_IO, 0);
rb_thread_call_without_gvl(getstr_func, rtn, RUBY_UBF_IO, 0);
return rb_locale_str_new_cstr(rtn);
}
@ -1955,12 +1956,12 @@ struct wgetch_arg {
int c;
};
static VALUE
static void *
wgetch_func(void *_arg)
{
struct wgetch_arg *arg = (struct wgetch_arg *)_arg;
arg->c = wgetch(arg->win);
return Qnil;
return 0;
}
/*
@ -1980,7 +1981,7 @@ window_getch(VALUE obj)
GetWINDOW(obj, winp);
arg.win = winp->window;
rb_thread_blocking_region(wgetch_func, (void *)&arg, RUBY_UBF_IO, 0);
rb_thread_call_without_gvl(wgetch_func, (void *)&arg, RUBY_UBF_IO, 0);
c = arg.c;
if (c == EOF) return Qnil;
if (rb_isprint(c)) {
@ -1996,7 +1997,7 @@ struct wgetstr_arg {
char rtn[GETSTR_BUF_SIZE];
};
static VALUE
static void *
wgetstr_func(void *_arg)
{
struct wgetstr_arg *arg = (struct wgetstr_arg *)_arg;
@ -2005,7 +2006,7 @@ wgetstr_func(void *_arg)
#else
wgetstr(arg->win, arg->rtn);
#endif
return Qnil;
return 0;
}
/*
@ -2022,7 +2023,7 @@ window_getstr(VALUE obj)
GetWINDOW(obj, winp);
arg.win = winp->window;
rb_thread_blocking_region(wgetstr_func, (void *)&arg, RUBY_UBF_IO, 0);
rb_thread_call_without_gvl(wgetstr_func, (void *)&arg, RUBY_UBF_IO, 0);
return rb_locale_str_new_cstr(arg.rtn);
}

Просмотреть файл

@ -1 +1 @@
curses.o: curses.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h
curses.o: curses.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h $(hdrdir)/thread.h

Просмотреть файл

@ -30,6 +30,7 @@ extern "C" {
#endif
#include <ruby.h>
#include <ruby/io.h>
#include <ruby/thread.h>
/*
* Check the OpenSSL version

Просмотреть файл

@ -90,12 +90,12 @@ struct dh_blocking_gen_arg {
int result;
};
static VALUE
static void *
dh_blocking_gen(void *arg)
{
struct dh_blocking_gen_arg *gen = (struct dh_blocking_gen_arg *)arg;
gen->result = DH_generate_parameters_ex(gen->dh, gen->size, gen->gen, gen->cb);
return Qnil;
return 0;
}
#endif
@ -123,7 +123,7 @@ dh_generate(int size, int gen)
dh_blocking_gen(&gen_arg);
} else {
/* there's a chance to unblock */
rb_thread_blocking_region(dh_blocking_gen, &gen_arg, ossl_generate_cb_stop, &cb_arg);
rb_thread_call_without_gvl(dh_blocking_gen, &gen_arg, ossl_generate_cb_stop, &cb_arg);
}
if (!gen_arg.result) {

Просмотреть файл

@ -87,12 +87,12 @@ struct dsa_blocking_gen_arg {
int result;
};
static VALUE
static void *
dsa_blocking_gen(void *arg)
{
struct dsa_blocking_gen_arg *gen = (struct dsa_blocking_gen_arg *)arg;
gen->result = DSA_generate_parameters_ex(gen->dsa, gen->size, gen->seed, gen->seed_len, gen->counter, gen->h, gen->cb);
return Qnil;
return 0;
}
#endif
@ -130,7 +130,7 @@ dsa_generate(int size)
dsa_blocking_gen(&gen_arg);
} else {
/* there's a chance to unblock */
rb_thread_blocking_region(dsa_blocking_gen, &gen_arg, ossl_generate_cb_stop, &cb_arg);
rb_thread_call_without_gvl(dsa_blocking_gen, &gen_arg, ossl_generate_cb_stop, &cb_arg);
}
if (!gen_arg.result) {
DSA_free(dsa);

Просмотреть файл

@ -85,12 +85,12 @@ struct rsa_blocking_gen_arg {
int result;
};
static VALUE
static void *
rsa_blocking_gen(void *arg)
{
struct rsa_blocking_gen_arg *gen = (struct rsa_blocking_gen_arg *)arg;
gen->result = RSA_generate_key_ex(gen->rsa, gen->size, gen->e, gen->cb);
return Qnil;
return 0;
}
#endif
@ -133,7 +133,7 @@ rsa_generate(int size, unsigned long exp)
rsa_blocking_gen(&gen_arg);
} else {
/* there's a chance to unblock */
rb_thread_blocking_region(rsa_blocking_gen, &gen_arg, ossl_generate_cb_stop, &cb_arg);
rb_thread_call_without_gvl(rsa_blocking_gen, &gen_arg, ossl_generate_cb_stop, &cb_arg);
}
if (!gen_arg.result) {
BN_free(e);

Просмотреть файл

@ -1110,11 +1110,11 @@ struct sendmsg_args_struct {
int flags;
};
static VALUE
static void *
nogvl_sendmsg_func(void *ptr)
{
struct sendmsg_args_struct *args = ptr;
return sendmsg(args->fd, args->msg, args->flags);
return (void *)sendmsg(args->fd, args->msg, args->flags);
}
static ssize_t
@ -1124,7 +1124,7 @@ rb_sendmsg(int fd, const struct msghdr *msg, int flags)
args.fd = fd;
args.msg = msg;
args.flags = flags;
return rb_thread_blocking_region(nogvl_sendmsg_func, &args, RUBY_UBF_IO, 0);
return (ssize_t)rb_thread_call_without_gvl(nogvl_sendmsg_func, &args, RUBY_UBF_IO, 0);
}
static VALUE
@ -1368,12 +1368,12 @@ rsock_recvmsg(int socket, struct msghdr *message, int flags)
return recvmsg(socket, message, flags);
}
static VALUE
static void *
nogvl_recvmsg_func(void *ptr)
{
struct recvmsg_args_struct *args = ptr;
int flags = args->flags;
return rsock_recvmsg(args->fd, args->msg, flags);
return (void *)rsock_recvmsg(args->fd, args->msg, flags);
}
static ssize_t
@ -1383,7 +1383,7 @@ rb_recvmsg(int fd, struct msghdr *msg, int flags)
args.fd = fd;
args.msg = msg;
args.flags = flags;
return rb_thread_blocking_region(nogvl_recvmsg_func, &args, RUBY_UBF_IO, 0);
return (ssize_t)rb_thread_call_without_gvl(nogvl_recvmsg_func, &args, RUBY_UBF_IO, 0);
}
#if defined(HAVE_ST_MSG_CONTROL)

Просмотреть файл

@ -1,5 +1,5 @@
SOCK_HEADERS = $(srcdir)/rubysocket.h $(hdrdir)/ruby/ruby.h $(arch_hdrdir)/ruby/config.h \
$(hdrdir)/ruby/defines.h $(hdrdir)/ruby/io.h \
$(hdrdir)/ruby/defines.h $(hdrdir)/ruby/io.h $(hdrdir)/ruby/thread.h \
$(srcdir)/addrinfo.h $(srcdir)/sockport.h constdefs.h $(top_srcdir)/internal.h
init.o: init.c $(SOCK_HEADERS)

Просмотреть файл

@ -154,12 +154,12 @@ struct getaddrinfo_arg
struct addrinfo **res;
};
static VALUE
static void *
nogvl_getaddrinfo(void *arg)
{
struct getaddrinfo_arg *ptr = arg;
return getaddrinfo(ptr->node, ptr->service,
ptr->hints, ptr->res);
return (void *)getaddrinfo(ptr->node, ptr->service,
ptr->hints, ptr->res);
}
#endif
@ -178,7 +178,7 @@ rb_getaddrinfo(const char *node, const char *service,
arg.service = service;
arg.hints = hints;
arg.res = res;
ret = (int)BLOCKING_REGION(nogvl_getaddrinfo, &arg);
ret = (int)rb_thread_call_without_gvl(nogvl_getaddrinfo, &arg, RUBY_UBF_IO, 0);
return ret;
#endif
}
@ -195,14 +195,14 @@ struct getnameinfo_arg
int flags;
};
static VALUE
static void *
nogvl_getnameinfo(void *arg)
{
struct getnameinfo_arg *ptr = arg;
return getnameinfo(ptr->sa, ptr->salen,
ptr->host, (socklen_t)ptr->hostlen,
ptr->serv, (socklen_t)ptr->servlen,
ptr->flags);
return (void *)getnameinfo(ptr->sa, ptr->salen,
ptr->host, (socklen_t)ptr->hostlen,
ptr->serv, (socklen_t)ptr->servlen,
ptr->flags);
}
#endif
@ -223,7 +223,7 @@ rb_getnameinfo(const struct sockaddr *sa, socklen_t salen,
arg.serv = serv;
arg.servlen = servlen;
arg.flags = flags;
ret = (int)BLOCKING_REGION(nogvl_getnameinfo, &arg);
ret = (int)rb_thread_call_without_gvl(nogvl_getnameinfo, &arg, RUBY_UBF_IO, 0);
return ret;
#endif
}

Просмотреть файл

@ -3,6 +3,7 @@
#include "ruby/ruby.h"
#include "ruby/io.h"
#include "ruby/thread.h"
#include "ruby/util.h"
#include "internal.h"
#include <stdio.h>

Просмотреть файл

@ -10,6 +10,7 @@
#include <zlib.h>
#include <time.h>
#include <ruby/io.h>
#include <ruby/thread.h>
#ifdef HAVE_VALGRIND_MEMCHECK_H
# include <valgrind/memcheck.h>
@ -916,7 +917,7 @@ zstream_end(struct zstream *z)
return Qnil;
}
static VALUE
static void *
zstream_run_func(void *ptr)
{
struct zstream_run_args *args = (struct zstream_run_args *)ptr;
@ -950,7 +951,7 @@ zstream_run_func(void *ptr)
}
}
return (VALUE)err;
return (void *)err;
}
/*
@ -994,7 +995,7 @@ zstream_run(struct zstream *z, Bytef *src, long len, int flush)
}
loop:
err = (int)rb_thread_blocking_region(
err = (int)rb_thread_call_without_gvl(
zstream_run_func, (void *)&args,
zstream_unblock_func, (void *)&args);

1
gc.c
Просмотреть файл

@ -15,6 +15,7 @@
#include "ruby/st.h"
#include "ruby/re.h"
#include "ruby/io.h"
#include "ruby/thread.h"
#include "ruby/util.h"
#include "eval_intern.h"
#include "vm_core.h"

Просмотреть файл

@ -826,6 +826,7 @@ void rb_thread_check_ints(void);
int rb_thread_interrupted(VALUE thval);
VALUE rb_thread_blocking_region(rb_blocking_function_t *func, void *data1,
rb_unblock_function_t *ubf, void *data2);
DEPRECATED(VALUE rb_thread_blocking_region());
#define RUBY_UBF_IO ((rb_unblock_function_t *)-1)
#define RUBY_UBF_PROCESS ((rb_unblock_function_t *)-1)
VALUE rb_mutex_new(void);

43
include/ruby/thread.h Normal file
Просмотреть файл

@ -0,0 +1,43 @@
/**********************************************************************
thread.h -
$Author: matz $
created at: Tue Jul 10 17:35:43 JST 2012
Copyright (C) 2007 Yukihiro Matsumoto
**********************************************************************/
#ifndef RUBY_THREAD_H
#define RUBY_THREAD_H 1
#if defined(__cplusplus)
extern "C" {
#if 0
} /* satisfy cc-mode */
#endif
#endif
#include "ruby/intern.h"
#if defined __GNUC__ && __GNUC__ >= 4
#pragma GCC visibility push(default)
#endif
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);
#if defined __GNUC__ && __GNUC__ >= 4
#pragma GCC visibility pop
#endif
#if defined(__cplusplus)
#if 0
{ /* satisfy cc-mode */
#endif
} /* extern "C" { */
#endif
#endif /* RUBY_THREAD_H */

Просмотреть файл

@ -294,16 +294,6 @@ const char *rb_objspace_data_type_name(VALUE obj);
/* Temporary. This API will be removed (renamed). */
VALUE rb_thread_io_blocking_region(rb_blocking_function_t *func, void *data1, int fd);
/* experimental.
* These APIs can be changed on Ruby 1.9.4 or later.
* We will change these APIs (spac, name and so on) if there are something wrong.
* If you use these APIs, catch up future changes.
*/
void *rb_thread_call_with_gvl(void *(*func)(void *), void *data1);
VALUE rb_thread_call_without_gvl(
rb_blocking_function_t *func, void *data1,
rb_unblock_function_t *ubf, void *data2);
/* io.c */
void rb_maygvl_fd_fix_cloexec(int fd);

14
io.c
Просмотреть файл

@ -13,6 +13,7 @@
#include "ruby/ruby.h"
#include "ruby/io.h"
#include "ruby/thread.h"
#include "dln.h"
#include "internal.h"
#include <ctype.h>
@ -5009,19 +5010,19 @@ struct sysopen_struct {
mode_t perm;
};
static VALUE
static void *
sysopen_func(void *ptr)
{
const struct sysopen_struct *data = ptr;
const char *fname = RSTRING_PTR(data->fname);
return (VALUE)rb_cloexec_open(fname, data->oflags, data->perm);
return (void *)rb_cloexec_open(fname, data->oflags, data->perm);
}
static inline int
rb_sysopen_internal(struct sysopen_struct *data)
{
int fd;
fd = (int)rb_thread_blocking_region(sysopen_func, data, RUBY_UBF_IO, 0);
fd = (int)rb_thread_call_without_gvl(sysopen_func, data, RUBY_UBF_IO, 0);
if (0 <= fd)
rb_update_max_fd(fd);
return fd;
@ -9733,7 +9734,7 @@ nogvl_copy_stream_read_write(struct copy_stream_struct *stp)
}
}
static VALUE
static void *
nogvl_copy_stream_func(void *arg)
{
struct copy_stream_struct *stp = (struct copy_stream_struct *)arg;
@ -9752,7 +9753,7 @@ nogvl_copy_stream_func(void *arg)
#ifdef USE_SENDFILE
finish:
#endif
return Qnil;
return 0;
}
static VALUE
@ -9938,7 +9939,8 @@ copy_stream_body(VALUE arg)
rb_fd_set(src_fd, &stp->fds);
rb_fd_set(dst_fd, &stp->fds);
return rb_thread_blocking_region(nogvl_copy_stream_func, (void*)stp, RUBY_UBF_IO, 0);
rb_thread_call_without_gvl(nogvl_copy_stream_func, (void*)stp, RUBY_UBF_IO, 0);
return Qnil;
}
static VALUE

Просмотреть файл

@ -13,6 +13,7 @@
#include "ruby/ruby.h"
#include "ruby/io.h"
#include "ruby/thread.h"
#include "ruby/util.h"
#include "internal.h"
#include "vm_core.h"
@ -628,7 +629,7 @@ struct waitpid_arg {
};
#endif
static VALUE
static void *
rb_waitpid_blocking(void *data)
{
rb_pid_t result;
@ -644,7 +645,7 @@ rb_waitpid_blocking(void *data)
result = wait4(arg->pid, arg->st, arg->flags, NULL);
#endif
return (VALUE)result;
return (void *)result;
}
rb_pid_t
@ -658,8 +659,8 @@ rb_waitpid(rb_pid_t pid, int *st, int flags)
arg.pid = pid;
arg.st = st;
arg.flags = flags;
result = (rb_pid_t)rb_thread_blocking_region(rb_waitpid_blocking, &arg,
RUBY_UBF_PROCESS, 0);
result = (rb_pid_t)rb_thread_call_without_gvl(rb_waitpid_blocking, &arg,
RUBY_UBF_PROCESS, 0);
if (result < 0) {
if (errno == EINTR) {
RUBY_VM_CHECK_INTS();

Просмотреть файл

@ -48,6 +48,7 @@
#include "gc.h"
#include "internal.h"
#include "ruby/io.h"
#include "ruby/thread.h"
#ifndef USE_NATIVE_THREAD_PRIORITY
#define USE_NATIVE_THREAD_PRIORITY 0
@ -1114,12 +1115,11 @@ rb_thread_blocking_region_end(struct rb_blocking_region_buffer *region)
* they will work without GVL, and may acquire GVL
* when GC is needed.
*/
VALUE
rb_thread_blocking_region(
rb_blocking_function_t *func, void *data1,
rb_unblock_function_t *ubf, void *data2)
void *
rb_thread_call_without_gvl(void *(*func)(void *), void *data1,
rb_unblock_function_t *ubf, void *data2)
{
VALUE val;
void *val;
rb_thread_t *th = GET_THREAD();
int saved_errno = 0;
@ -1156,14 +1156,13 @@ rb_thread_io_blocking_region(rb_blocking_function_t *func, void *data1, int fd)
return val;
}
/* alias of rb_thread_blocking_region() */
VALUE
rb_thread_call_without_gvl(
rb_thread_blocking_region(
rb_blocking_function_t *func, void *data1,
rb_unblock_function_t *ubf, void *data2)
{
return rb_thread_blocking_region(func, data1, ubf, data2);
void *(*f)(void*) = (void *(*)(void*))func;
return (VALUE)rb_thread_call_without_gvl(f, data1, ubf, data2);
}
/*