diff options
author | Wei Wang <wvw@google.com> | 2018-01-02 11:21:11 -0800 |
---|---|---|
committer | Wei Wang <wvw@google.com> | 2018-06-06 11:29:21 -0700 |
commit | bb89b2340baeaa1dc3b4ef9e570a3ac08826ae55 (patch) | |
tree | 1d909de7a87e51f7d7c02be5ea36f31de7f70266 /libperfmgr | |
parent | a8768fc41aa8fce5eb1ed272be4ca6219228c4ad (diff) | |
download | extras-bb89b2340baeaa1dc3b4ef9e570a3ac08826ae55.tar.gz |
libperfmgr: Remove request when returning 0ms
There is a small chance a request expire time is less than 1ms. In this
case, the request will be removed.
Test: libperfmgr_test
(cherry picked from commit 09fbfae2d8c3a9d2d071bbd8a29d3ffd46e0f13d)
Change-Id: I1928be09e40302f6aa949dab920cd6aa08dac014
Diffstat (limited to 'libperfmgr')
-rw-r--r-- | libperfmgr/RequestGroup.cc | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/libperfmgr/RequestGroup.cc b/libperfmgr/RequestGroup.cc index 1c7a96ae..7f7ddf4b 100644 --- a/libperfmgr/RequestGroup.cc +++ b/libperfmgr/RequestGroup.cc @@ -47,16 +47,13 @@ bool RequestGroup::GetExpireTime(std::chrono::milliseconds* expire_time) { bool active = false; for (auto it = request_map_.begin(); it != request_map_.end();) { - if (it->second <= now) { + auto duration = std::chrono::duration_cast<std::chrono::milliseconds>( + it->second - now); + if (duration <= std::chrono::milliseconds::zero()) { it = request_map_.erase(it); } else { + *expire_time = std::min(duration, *expire_time); active = true; - auto duration = - std::chrono::duration_cast<std::chrono::milliseconds>( - it->second - now); - if (duration < *expire_time) { - *expire_time = duration; - } ++it; } } |