-
Notifications
You must be signed in to change notification settings - Fork 29
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
Create callback based on file descriptor monitoring #190
Conversation
Proof-of-concept of waiting on file descriptors instead of the passing of time. This implementation is totally fake in that it actually relies on polling under the hood. I'm hoping it will be helpful in illustrating how such a function could be useful.
…ng without resorting to tryCatch
Thinking out loud: Again, impressed at your pace in getting this done. I haven't actually run the code but I will assume for now that it works as advertised. I looked at later_posix.cpp for the first time in a long while and (re)learned that the It makes me a little itchy that there is a new thread being launched for each later_fd call. Probably not noticeable to any of our users, but it's such a common idiom to have a single thread/loop calling select/poll/epoll for many jobs that a dedicated thread per callback feels a bit shocking. I'm fine if you want to leave this the way it is for now while we complete the end-to-end scenario. |
Adding a note that I've tweaked the error behaviour slightly in 0fa8ed3. Before, I had During initial integration testing, I came across cases where curl could return no files descriptors at the start of a transaction. Probably user error on my part, but I can't say for certain yet. But this led me to think it could be helpful for others in a similar situation, where either the callback can handle the length zero response or it just needs to loop again. |
We need test_that("loop_empty() reflects later_fd callbacks", {
# Windows can't `later_fd` on `file()` probably?
testthat::skip_on_os("windows")
expect_true(loop_empty())
f1 <- file()
on.exit(close(f1))
cancel <- later_fd(~{}, f1)
expect_false(loop_empty())
cancel()
expect_true(loop_empty())
later_fd(~{}, f1, timeout = 0)
expect_false(loop_empty())
run_now()
expect_true(loop_empty())
}) |
Just to confirm that this is noted, and I will be addressing it. |
Looks great, I'm really excited!! GitHub won't let me mark this PR as Approved as I technically opened the PR, but LGTM 👍 Let me know if you were planning to make any more changes, if not I'll go ahead and merge! |
Oh yes I have some final cleanups - will commit shortly! |
And done. All good from my side. I had planned on writing you a note on the changes but you had already picked it up! You can see I've embraced RAII :) Thanks for your thorough code review on this PR. |
…r() now we retain a shared_ptr to the registry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please proceed with the merge, thanks!
You keep saying you're done and then adding more commits 🤣 I'm pressing the button!! |
🥂🍾 |
No description provided.