Skip to content
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

event/TimerList: Add custom compare for android #2020

Closed
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
13 changes: 12 additions & 1 deletion src/event/TimerList.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@

#pragma once

#include <compare>

#include "Chrono.hxx"
#include "event/Features.h"
#include "util/IntrusiveTreeSet.hxx"

class FineTimerEvent;

struct custom_compare {
auto operator()(const std::chrono::steady_clock::time_point& lhs,
const std::chrono::steady_clock::time_point& rhs) const {
return lhs < rhs ? std::strong_ordering::less
: lhs == rhs ? std::strong_ordering::equal
: std::strong_ordering::greater;
}
};

/**
* A list of #FineTimerEvent instances sorted by due time point.
*/
Expand All @@ -19,7 +30,7 @@ class TimerList final {
};

IntrusiveTreeSet<FineTimerEvent,
IntrusiveTreeSetOperators<FineTimerEvent, GetDue>> timers;
IntrusiveTreeSetOperators<FineTimerEvent, GetDue, custom_compare>> timers;

public:
TimerList();
Expand Down
Loading