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
Common: Blocking Loop (extracted from Fifo.cpp) #2470
Conversation
degasus> so from a testing point of view, PR 2470 is fine? |
Wait(); | ||
} | ||
|
||
bool IsRunning() |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
edb6efb
to
f68d06f
Compare
/* | ||
* This class provides a synchronized loop. | ||
* It's a thread-safe way to trigger a new iteration without busy loops. | ||
* It's optimized for high-usage iterations which usually are already runing while it's triggered often. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
||
// Mainloop of this object. | ||
// The payload callback is called at least as often as it's needed to match the Set() requirements. | ||
template<class F> void Run(F&& payload) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
loop.Wait(); | ||
EXPECT_EQ(signaled.load(), received.load()); | ||
|
||
for (int j = 0; j < 100; j++) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Okay. I think I've convinced myself that the atomic logic is correct, so sorry for doubting you @degasus :)
|
@comex Thanks for your huge efforts, I've tried to implement your suggestions. Missing:
|
It's now a new helper function within common.
This merges two atomic<bool> into one atomic<int>. We did move the bit from one bool to another, now we can use operator--.
JMC47> seems exactly the same |
a3cb4f1
to
9c730b0
Compare
FifoCI detected that this change impacts graphical rendering. Here are the behavior differences detected by the system:
automated-fifoci-reporter |
Haven't thought about the new version as thoroughly as the last one, but it seems reasonable. Thanks! |
Common: Blocking Loop (extracted from Fifo.cpp)
This PR tries to extract the synchronized main loop of our fifo as shared file within Common.
The new Common Class represent a way to implement a "busy loop" which sleeps on no work. It is optimized for a high frequent pushing of new data while the loop is already running.