From 24a2f6db438537ff81081a41b5ebf02cda2dec57 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 26 Feb 2011 16:35:56 -0800 Subject: shorten calls to rb_thread_blocking_region Long lines bother me --- ext/io_splice/io_splice_ext.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'ext/io_splice') diff --git a/ext/io_splice/io_splice_ext.c b/ext/io_splice/io_splice_ext.c index 268179f..35dc4a2 100644 --- a/ext/io_splice/io_splice_ext.c +++ b/ext/io_splice/io_splice_ext.c @@ -90,8 +90,14 @@ rb_thread_blocking_region( # define RARRAY_LEN(s) (RARRAY(s)->len) #endif +static VALUE io_run(rb_blocking_function_t *fn, void *data) +{ + return rb_thread_blocking_region(fn, data, RUBY_UBF_IO, 0); +} + /* * Releases GVL only iff blocking I/O is used. + * Only use this if all file descriptors in data are pipes. * We'll trust programmers who use non-blocking I/O explicitly to * want the fastest possible performance without resorting to threads, * so releasing and them immediately reacquiring the GVL would be @@ -101,7 +107,7 @@ static VALUE nb_io_run(rb_blocking_function_t *fn, void *data, unsigned flags) { if (flags & SPLICE_F_NONBLOCK) return fn(data); - return rb_thread_blocking_region(fn, data, RUBY_UBF_IO, 0); + return io_run(fn, data); } struct splice_args { @@ -180,7 +186,7 @@ VALUE fd_in, VALUE off_in, VALUE fd_out, VALUE off_out, VALUE len, VALUE flags) struct splice_args a; prepare_splice_args(&a, fd_in, off_in, fd_out, off_out, len, flags); - n = (long)rb_thread_blocking_region(nogvl_splice, &a, RUBY_UBF_IO, 0); + n = (long)io_run(nogvl_splice, &a); if (n == 0) rb_eof_error(); if (n < 0) @@ -195,7 +201,7 @@ VALUE fd_in, VALUE off_in, VALUE fd_out, VALUE off_out, VALUE len, VALUE flags) struct splice_args a; prepare_splice_args(&a, fd_in, off_in, fd_out, off_out, len, flags); - n = (long)rb_thread_blocking_region(nogvl_splice, &a, RUBY_UBF_IO, 0); + n = (long)io_run(nogvl_splice, &a); if (n == 0) return Qnil; if (n < 0) { -- cgit v1.2.3-24-ge0c7