#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();
|
|
}
|
|
};
|