ClickHouse/src/Common/StatusInfo.h

38 lines
840 B
C++
Raw Normal View History

#pragma once
#include <stddef.h>
#include <cstdint>
#include <utility>
#include <atomic>
#include <Core/Types.h>
#include <mutex>
#include <unordered_map>
namespace CurrentStatusInfo
{
2020-03-12 12:29:28 +00:00
using Status = size_t;
using Key = std::string;
2020-03-12 12:29:28 +00:00
const char * getName(Status event);
const char * getDocumentation(Status event);
const std::vector<std::pair<String, Int8>> & getAllPossibleValues(Status event);
2020-03-12 12:09:15 +00:00
extern std::unordered_map<String, Int8> values[];
extern std::mutex locks[];
2020-03-12 12:29:28 +00:00
Status end();
2020-03-12 12:29:28 +00:00
inline void set(Status status, Key key, Int8 value)
{
2020-03-12 12:29:28 +00:00
std::lock_guard<std::mutex> lock(locks[status]);
values[status][key] = value;
}
2020-03-12 12:29:28 +00:00
inline void unset(Status status, Key key)
{
2020-03-12 12:29:28 +00:00
std::lock_guard<std::mutex> lock(locks[status]);
values[status].erase(key);
}
}