CxCli: better TryRemove.

GitOrigin-RevId: ef4394f1dd2d1fdf6609412ec666954316aafa66
This commit is contained in:
levlam 2018-02-22 23:34:09 +03:00
parent e3efbd9c84
commit c8a784f0ca

View File

@ -49,9 +49,15 @@ public:
value = it->second;
return true;
}
void TryRemove(Key key, Value &value) {
bool TryRemove(Key key, Value &value) {
std::lock_guard<std::mutex> guard(mutex_);
impl_.erase(key);
auto it = impl_.find(key);
if (it == impl_.end()) {
return false;
}
value = std::move(it->second);
impl_.erase(it);
return true;
}
Value &operator [] (Key key) {
std::lock_guard<std::mutex> guard(mutex_);