Skip to content

Conversation

@shikokuchuo
Copy link
Member

Hi @jcheng5,

This is a re-write of the persistent wait thread I had devised. I implemented the logic for nanonext in r-lib/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.

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