Closed kassane closed 1 year ago
@kprotty, follow your implementation suggestion based on some examples found in the asio source.
Although it was a leap for me!
@kprotty,
I recognize that asio has more sophisticated features that perhaps lean towards your experiment as an example: asio:: awaitable<T>
(C++20) std coroutines enhanced.
So far I've had a lot of difficulty using it due to the need for some esoteric cxxflags from the library. (e.g.: -DASIO_HAS_CO_AWAIT
).
@kprotty,
(std::async
+ std::deque
)
I'm looking into this solution, maybe it can help.
https://github.com/akselsd/AsyncQuicksort/blob/master/quicksort.hpp#L64-L97
@kprotty , my last commit fix:
filling
shuffling
running
Values before co_await: 0 - 10000000
took 929ms
Edit
the change only uses insertSort
or std::sort
.
@kprotty ,
new commit - Refactored code!!!
filling
shuffling
running
took 1494ms
The new refactored version of c++20 coroutines works, slightly faster than strand.
@kprotty,
I think that the rabbit hole is currently emerging. Would it be valid to optimize further after this new refactoring? I've tried to avoid using as much of the complexity of TMP (template metaprogramming) as possible!
Hi @madmongo1,
First, I apologize for mentioning it without contacting you previously.
We are trying to get the best "possible" solution in an asynchronous qsort. I don't have much experience in using coroutines nor asio standalone coroutines.
Based on current solution which returns ±1230ms (coro-qsort).
In the last Review it is noticed that co_spawn
receives an awaitable function that is immediately destroyed. That would happen on every call, right?
Note: Development environment would be equivalent to (zig c++
= clang with libc++
).
No guarantee it's the best implementation or anything like that (I'm not expert in concurrent programming). However, another alternative for a library that is popular with C++ programmers is missing.