Skip to content
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

Persistent later_fd() wait thread #195

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

shikokuchuo
Copy link
Collaborator

Hi @jcheng5,

This is a re-write of the persistent wait thread I had devised. I implemented the logic for nanonext in shikokuchuo/nanonext@c04c5d9 and I've ported it back here for later (as this was the original inspiration).

Main features

  • PersistentThread class with encapsulated creation / destruction logic.
  • Uses the existing Mutex / ConditionVariable / Guard classes, relying on RAII.
  • Requires only one integer busy status 0, or 1 (or -1 to signal an exit).
  • Everything done safely under mutex protection.

It covers our use case for sequential curl socket waits (streaming and non-streaming in httr2 and elmer), and is no worse for concurrent waits (which will use the same threads as before).

Substantially the same mechanism has already shipped in nanonext 1.3.1 and is being used for interruptible waits in mirai and any issues would show up right across the mirai/crew/targets stack.

It's your call whether you think the added complexity is worth it. We don't have to include this initially if you want to ship the existing implementation. This is a (substantially complete) draft but still requires some polish if you decide to go ahead with it.

@shikokuchuo shikokuchuo marked this pull request as draft November 19, 2024 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant