Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion runtime/test/display_white_cache_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ int main() {
leonida::DisplayWhiteCache cache([&] { return windows.load(); }, std::chrono::hours(1));
std::this_thread::sleep_for(20ms); // the worker is in its wait by now
ok &= check(cache.reads() == 0, "nothing is read before the first HDR10 present asks");
ok &= check(cache.get() == 0.0f, "the first get() has no value yet (the caller falls back to 203)");
// The first get() is what wakes the worker, so by the time it returns the read may already have
// landed: scheduling decides whether value_ is still empty. Accept both outcomes and assert the
// part that does not race - that it never returns anything but "no value" or the fresh read.
const float first = cache.get();
ok &= check(first == 0.0f || first == 240.0f,
"the first get() returns no value yet, or the value it woke the worker to read");
ok &= check(within(2s, [&] { return cache.reads() == 1; }), "the first get() wakes the worker to read now");
ok &= check(within(2s, [&] { return cache.get() == 240.0f; }), "and the value it read is cached");
windows = 300.0f;
Expand Down
Loading