Coroutines aren't great, even C++26 is explicitly avoiding them for its foundational concurrency model.
In any case a good concurrency library doesn't need more than C++14.
spacechild1 1 days ago [-]
In my understanding, senders/receivers is a more generalized concurrency model, but it has been designed to play well with coroutines.
pjmlp 1 days ago [-]
Is it? Senders/receivers is based on NVidias experience using them on CUDA.
Naturally I haven't followed them that much, given how far away C++26 is from being usable for portable code.
Compilers are finally getting good enough with C++20 support for updating the default version.
hiyfsch 2 days ago [-]
Just because coroutines exist doesn’t mean everything should use them for concurrency.
Why would it be better? It’s pretty easy to set up threads in general.
Rohansi 2 days ago [-]
Threads use more system resources than coroutines so it can be a big deal when you can potentially have thousands of them running.
hiyfsch 1 days ago [-]
Yeah I guess also depends on the problem space. For example, dedicated threads doing something versus a bunch of short-lived asynchronous tasks that need scheduling anyhow.
If a bunch of tasks need to be schedule best not to have to reinvent the wheel on that if possible.
If there’s longer running tasks the benefits probably are less noticeable.
alfiedotwtf 2 days ago [-]
The management to handle Threading and IO and not get it wrong is pretty high unless you’re using something like Rust because it guarantees you’re safe, vs letting the routine runtime management handle everything for you for free
whizzter 2 days ago [-]
Nah, coroutines/async/etc often lives in various threads (ie, the workers can schedule one of them on different threads during the lifetime and they live concurrently), so you still have all the issues of threading (+ new ones since things like thread-local variables aren't reliable if an async/coroutines moves threads between calls).
The main benefit is not having the cost of threads, f.ex. a default thread on Windows has something like 500k of stack iirc, scale that to 10000 concurrent requests and you're looking at 5gb of memory _just for stacks_, compared to a couroutine,etc that has perhaps a few kb's of usage (even if in deep stack-traces).
This is why we have stuff like io_uring these days, the bottleneck moved to the kernel calls (especially with Spectre style attacks) when concurrent costs in the applications went down.
menaerus 2 days ago [-]
> Nah, coroutines/async/etc often lives in various threads (ie, the workers can schedule one of them on different threads during the lifetime and they live concurrently), so you still have all the issues of threading (+ new ones since things like thread-local variables aren't reliable if an async/coroutines moves threads between calls).
In cooperative scheduling how is it possible to have two coroutines running concurrently?
whizzter 2 days ago [-]
You're thinking of older early coroutines or in singlethreaded runtimes (JS).
It's M:N threading, most logical threads/tasks are more lightweight than full OS threads, the logical ones should preferably behave cooperatively but they can be scheduled onto any number of real worker threads (usually these systems picks something like 2x worker threads compared to real CPU/Core count to manage some codepaths not being as well behaved).
Erlang and .NET(with Task/async) uses this model, iirc modern Java does this also (but hides it) and I'd be surprised if the modern async Rust or C++ variations didn't do this as well.
pjmlp 18 hours ago [-]
C++20 co-routines model is based on .NET ones, as the original model was proposed by Microsoft and inspired on WinRT work.
If you know how to create asyncable types on .NET, the magic methods expected by C++ compiler will feel familiar.
ddorian43 2 days ago [-]
> aren't reliable if an async/coroutines moves threads between calls
Then just don't move them between threads and you're good with thread locals, no?
whizzter 2 days ago [-]
Iirc often the frameworks don't have worker affinity, anyhow environments like .NET has "AsyncLocal" to provide an aware alternative.
RossBencina 2 days ago [-]
Agree that the code examples look like communicating sequential processes (CSP) and/or async/await-style concurrency (i.e. co-routines in C++). To me this is not "Actors" at all. Actors don't "wait", they receive and send messages, and optionally specify the behavior for handling the next message.
d4ng 2 days ago [-]
What are actors doing between finishing processing the last message and receiving the next one?
mgaunard 2 days ago [-]
yield to the event loop
d4ng 2 days ago [-]
So they're waiting.
mgaunard 1 days ago [-]
not really, they yield to other event sources, which is the opposite of waiting (which blocks forward progress and is a violation of real-time guarantees)
d4ng 1 days ago [-]
The actor itself can be said to be waiting. When it yields, the thread is then able to run another actor which was waiting on a message, and which then has a message on the queue.
mgaunard 11 hours ago [-]
That sounds like a misunderstanding of how the actor model works. An actor doesn't wait. It's an event-driven system, it doesn't get to own and decide when messages get fed to it.
d4ng 7 hours ago [-]
Are there any actor system implementations that you know of that work differently?
DSingularity 1 days ago [-]
I think these things can be equivalent. It all depends on the definition of wait.
The simple example can be x86 with monitor/mwait instructions. These will suspend a hardware thread until it can be awoken when the memory write happens to the monitored address. Nothing happens on that cpu thread in the meanwhile. Yet at the same time if things are being virtualized the higher authority exists and it can do something else with the CPU until the write. Same for OS type of event synchronization like Linux futex.
I would argue that the wait abstraction is more powerful. The alternative isn’t powerful enough to enable these kinds of “wake me when I can be useful again” behaviors.
Why has FoundationDB not been professionalised? Better website, better docs, official GUI?
Is Apple responsible for preventing its wider uptake? Or alternative databases stronger?
fidotron 2 days ago [-]
Because it converts all normal DBA tasks into development tasks. If this fits your org (and at huge scale it is more likely) then that's fine, but for small/mid/growth places that can be a PITA.
There does seem to be more effort going into an SQL layer, but it's very hard to know what the state of layer dev and direction is these days, especially if you're not located near core devs.
Dave_Rosenthal 1 days ago [-]
Great Q--it's weird that Apple, Snowflake, and the other big contributors have put essentially zero calories into documentation/website/etc.
There has been some movement lately, though. I'm not sure who exactly to thank, but "the community" created a new unofficial resource for getting going with FoundationDB: https://foundationdb.vercel.app/7.3/
Also how is the supposed Swift rewrite going on?
In any case a good concurrency library doesn't need more than C++14.
Naturally I haven't followed them that much, given how far away C++26 is from being usable for portable code.
Compilers are finally getting good enough with C++20 support for updating the default version.
Why would it be better? It’s pretty easy to set up threads in general.
If a bunch of tasks need to be schedule best not to have to reinvent the wheel on that if possible.
If there’s longer running tasks the benefits probably are less noticeable.
The main benefit is not having the cost of threads, f.ex. a default thread on Windows has something like 500k of stack iirc, scale that to 10000 concurrent requests and you're looking at 5gb of memory _just for stacks_, compared to a couroutine,etc that has perhaps a few kb's of usage (even if in deep stack-traces).
This is why we have stuff like io_uring these days, the bottleneck moved to the kernel calls (especially with Spectre style attacks) when concurrent costs in the applications went down.
In cooperative scheduling how is it possible to have two coroutines running concurrently?
It's M:N threading, most logical threads/tasks are more lightweight than full OS threads, the logical ones should preferably behave cooperatively but they can be scheduled onto any number of real worker threads (usually these systems picks something like 2x worker threads compared to real CPU/Core count to manage some codepaths not being as well behaved).
Erlang and .NET(with Task/async) uses this model, iirc modern Java does this also (but hides it) and I'd be surprised if the modern async Rust or C++ variations didn't do this as well.
If you know how to create asyncable types on .NET, the magic methods expected by C++ compiler will feel familiar.
Then just don't move them between threads and you're good with thread locals, no?
The simple example can be x86 with monitor/mwait instructions. These will suspend a hardware thread until it can be awoken when the memory write happens to the monitored address. Nothing happens on that cpu thread in the meanwhile. Yet at the same time if things are being virtualized the higher authority exists and it can do something else with the CPU until the write. Same for OS type of event synchronization like Linux futex.
I would argue that the wait abstraction is more powerful. The alternative isn’t powerful enough to enable these kinds of “wake me when I can be useful again” behaviors.
Flow: Actor-based language for C++, used by FoundationDB - https://news.ycombinator.com/item?id=46191763 - Dec 2025 (53 comments)
Is Apple responsible for preventing its wider uptake? Or alternative databases stronger?
There does seem to be more effort going into an SQL layer, but it's very hard to know what the state of layer dev and direction is these days, especially if you're not located near core devs.
There has been some movement lately, though. I'm not sure who exactly to thank, but "the community" created a new unofficial resource for getting going with FoundationDB: https://foundationdb.vercel.app/7.3/