Skip to content

Instantly share code, notes, and snippets.

@methodmissing
Created July 4, 2009 01:37
Show Gist options
  • Select an option

  • Save methodmissing/140393 to your computer and use it in GitHub Desktop.

Select an option

Save methodmissing/140393 to your computer and use it in GitHub Desktop.
static VALUE
internal_read_func(void *ptr)
{
struct io_internal_struct *iis = (struct io_internal_struct*)ptr;
return read(iis->fd, iis->buf, iis->capa);
}
static VALUE
internal_write_func(void *ptr)
{
struct io_internal_struct *iis = (struct io_internal_struct*)ptr;
return write(iis->fd, iis->buf, iis->capa);
}
static int
rb_read_internal(int fd, void *buf, size_t count)
{
struct io_internal_struct iis;
iis.fd = fd;
iis.buf = buf;
iis.capa = count;
return rb_thread_blocking_region(internal_read_func, &iis, RUBY_UBF_IO, 0);
}
static int
rb_write_internal(int fd, void *buf, size_t count)
{
struct io_internal_struct iis;
iis.fd = fd;
iis.buf = buf;
iis.capa = count;
return rb_thread_blocking_region(internal_write_func, &iis, RUBY_UBF_IO, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment