10225501448 李度 10225101546 陈胤遒 10215501422 高宇菲
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
667 B

#include "fielddb/field_db.h"
using namespace fielddb;
class ThreadSafeSet
{
private:
std::set<std::string> keys;
std::mutex setMutex;
public:
ThreadSafeSet(){}
void insert(std::string key){
std::lock_guard<std::mutex> lock(setMutex);
keys.insert(key);
}
void erase(std::string key){
std::lock_guard<std::mutex> lock(setMutex);
keys.erase(key);
}
void clear(){
std::lock_guard<std::mutex> lock(setMutex);
keys.clear();
}
size_t size(){
std::lock_guard<std::mutex> lock(setMutex);
return keys.size();
}
bool haveKey(std::string key){
return std::find(keys.begin(), keys.end(), key) != keys.end();
}
};