Freshen streams when we write to them

This commit is contained in:
flamingcow
2019-05-12 08:56:57 -07:00
parent d29157c1ac
commit b079f48367
3 changed files with 15 additions and 3 deletions

View File

@@ -5,7 +5,7 @@ namespace firesse {
void Index::Add(Stream* stream) {
std::lock_guard l(mu_);
// Implicitly freshest
stream->last_message_time_ = std::chrono::steady_clock::now();
stream->fresher_ = nullptr;
stream->staler_ = freshest_;
if (stream->staler_) {
@@ -36,4 +36,15 @@ void Index::Remove(Stream* stream) {
}
}
void Index::Freshen(Stream* stream) {
std::lock_guard l(mu_);
if (freshest_ == stream) {
// Shortcut
stream->last_message_time_ = std::chrono::steady_clock::now();
return;
}
Remove(stream);
Add(stream);
}
} // namespace firesse