Replies: 4 comments 1 reply
-
The asynchronous implementation of libfv is based on the thread pool in boost.asio. The thread pool interface is open and supports reuse under the library permission mode. If you have a good idea, I would also like to improve it to support concurrencpp or implement easier thread pool reuse. |
Beta Was this translation helpful? Give feedback.
-
Hi there, and sorry for the very late response, I was busy with personal issues and didn't have much time to do concurrencpp related things.
So, the problem here is the coroutine-executor integration and less about the coroutines themselves. different coroutines implementation can (theoretically) work with each other without causing any problem. for example, concurrencpp coroutines can call and await cppcoro coroutines, and vice-versa. it's when you want to mix different executor/scheduler types when things can turn ugly.
My suggestion is to pick one threadpool implementation, and to try to use that and only that as much as possible. this can be acheived by:
lib_a::do_something_async().then([lib_b_threadpool](auto result){
lib_b_threadpool.post([result]{
...
});
});
auto result = co_await lib_a::do_something_async();
co_await resume_on(lib_b_threadpool);
//use result as originally intended
As for performance, if you go with the suggestions I have given, the performance penalty is minimal. As for development, I really need to see the code base to judge but sharing one threadpool across multiple libraries is doable, if the different libraries provide those integration points (callbacks, I hope it helps! |
Beta Was this translation helpful? Give feedback.
-
Actually this problem is solved when a coroutine library becomes part of the standard library ;) |
Beta Was this translation helpful? Give feedback.
-
If you think that std::execution will solve anything I have bad news for you.. |
Beta Was this translation helpful? Give feedback.
-
It seems like there are dozens or even hundreds of asynchronous implementations for C++. This means that a complex program may have dependencies creating a handful of completely independent thread pools.
For a particular application I have been working on I have library dependencies maintaining at least 4 completely independent thread pools. If you analyze the dependencies, you see that 1,2, and 3 are all networking based.
In my particular use case, there is no fear of running out of system resources, but it seems that this duplication of effort is a potential issue for C++ in general. It may also be limiting the usefulness of some libraries in high performance or tight resource environments.
Do you think that the introduction of co-routines into c++ without a standardized networking library will lead to further fragmentation in the ecosystem? Libraries like libfv by @fawdlstty duplicate some of the feature set of concurrencpp, but, from my understanding, don't share the same thread pools.
How can this fragmentation and duplication of effort be minimized?
Are there any strategies for sharing thread pools?
Is there a way for library authors and application developers to avoid coupling their code to a particular co-routine / concurrency library?
What additional performance or development costs would developers incur from trying to maintain this independence?
Beta Was this translation helpful? Give feedback.
All reactions