summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2021-06-26 10:17:26 +1200
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2021-07-01 11:23:03 +1200
commit42130a64f02294dc8025af3a51bda518c67ab33d (patch)
treee81c181770e4cc9d3e87e960a25a870e9a4774f5 /thread.c
parent9c9531950c007872d7726f050a1dc0cb6f8f0490 (diff)
Replace copy coroutine with pthread implementation.
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/thread.c b/thread.c
index f7372d3dd2..47bbb4257c 100644
--- a/thread.c
+++ b/thread.c
@@ -1798,23 +1798,24 @@ rb_thread_io_blocking_region(rb_blocking_function_t *func, void *data1, int fd)
rb_execution_context_t * volatile ec = GET_EC();
volatile int saved_errno = 0;
enum ruby_tag_type state;
- COROUTINE_STACK_LOCAL(struct waiting_fd, wfd);
- wfd->fd = fd;
- wfd->th = rb_ec_thread_ptr(ec);
+ struct waiting_fd waiting_fd = {
+ .fd = fd,
+ .th = rb_ec_thread_ptr(ec)
+ };
RB_VM_LOCK_ENTER();
{
- list_add(&rb_ec_vm_ptr(ec)->waiting_fds, &wfd->wfd_node);
+ list_add(&rb_ec_vm_ptr(ec)->waiting_fds, &waiting_fd.wfd_node);
}
RB_VM_LOCK_LEAVE();
EC_PUSH_TAG(ec);
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
- BLOCKING_REGION(wfd->th, {
- val = func(data1);
- saved_errno = errno;
- }, ubf_select, wfd->th, FALSE);
+ BLOCKING_REGION(waiting_fd.th, {
+ val = func(data1);
+ saved_errno = errno;
+ }, ubf_select, waiting_fd.th, FALSE);
}
EC_POP_TAG();
@@ -1824,13 +1825,12 @@ rb_thread_io_blocking_region(rb_blocking_function_t *func, void *data1, int fd)
*/
RB_VM_LOCK_ENTER();
{
- list_del(&wfd->wfd_node);
- COROUTINE_STACK_FREE(wfd);
+ list_del(&waiting_fd.wfd_node);
}
RB_VM_LOCK_LEAVE();
if (state) {
- EC_JUMP_TAG(ec, state);
+ EC_JUMP_TAG(ec, state);
}
/* TODO: check func() */
RUBY_VM_CHECK_INTS_BLOCKING(ec);