1 /** 2 * Copyright 2021 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include "fl/server/local_meta_store.h" 18 19 namespace mindspore { 20 namespace fl { 21 namespace server { remove_value(const std::string & name)22void LocalMetaStore::remove_value(const std::string &name) { 23 std::unique_lock<std::mutex> lock(mtx_); 24 if (key_to_meta_.count(name) != 0) { 25 (void)key_to_meta_.erase(key_to_meta_.find(name)); 26 } 27 } 28 has_value(const std::string & name)29bool LocalMetaStore::has_value(const std::string &name) { 30 std::unique_lock<std::mutex> lock(mtx_); 31 return key_to_meta_.count(name) != 0; 32 } 33 set_curr_iter_num(size_t num)34void LocalMetaStore::set_curr_iter_num(size_t num) { 35 std::unique_lock<std::mutex> lock(mtx_); 36 curr_iter_num_ = num; 37 } 38 curr_iter_num()39const size_t LocalMetaStore::curr_iter_num() { 40 std::unique_lock<std::mutex> lock(mtx_); 41 return curr_iter_num_; 42 } 43 } // namespace server 44 } // namespace fl 45 } // namespace mindspore 46