-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compatibility with fiber scheduler. #92
Comments
Would be more efficient if we could use |
I'm not sure where this is used, but it might be better to use the rb_wait_* functions too: |
That's about the extent of my knowledge at the moment. I'd happy to help make whatever changes are desirable here, but I'll probably need to learn a lot more about the fiber scheduler, the difference between rb_wait_for_single_fd and rb_io_wait, etc. |
I am happy to make a PR if you are willing to work with me getting it merged? |
Yes, I can do that! |
I started playing around with the code. static int _cb_ruby_wait(trilogy_sock_t *sock, trilogy_wait_t wait)
{
struct timeval *timeout = NULL;
int wait_flag = 0;
switch (wait) {
case TRILOGY_WAIT_READ:
timeout = &sock->opts.read_timeout;
wait_flag = RB_WAITFD_IN;
break;
case TRILOGY_WAIT_WRITE:
timeout = &sock->opts.write_timeout;
wait_flag = RB_WAITFD_OUT;
break;
case TRILOGY_WAIT_HANDSHAKE:
timeout = &sock->opts.connect_timeout;
wait_flag = RB_WAITFD_IN;
break;
default:
return TRILOGY_ERR;
}
if (timeout->tv_sec == 0 && timeout->tv_usec == 0) {
timeout = NULL;
}
int fd = trilogy_sock_fd(sock);
if (rb_wait_for_single_fd(fd, wait_flag, timeout) <= 0)
return TRILOGY_SYSERR;
return 0;
} The The I think the callback argument will need to be added or the existing context should be changed to store the struct trilogy_ctx {
trilogy_conn_t conn;
VALUE io;
char server_version[TRILOGY_SERVER_VERSION_SIZE + 1];
unsigned int query_flags;
}; Do you have any thoughts about how to best achieve this? Maybe we can add a Also, just for your reference, naming conventions with trailing |
I've opened a draft PR with the above changes. |
Hello, thanks for this awesome work.
Is this adapter compatible with the fiber scheduler?
Thanks.
The text was updated successfully, but these errors were encountered: