blob: 54339e1749ba65daa0fa01a761b0ee68a50c8f22 [file] [log] [blame]
#include "stats_collection.h"
#include <mutex>
namespace state {
bool connected_to_voltha = false;
bool activated = false;
std::mutex state_lock;
bool is_connected() {
return connected_to_voltha;
}
bool is_activated() {
return activated;
}
void connect() {
state_lock.lock();
connected_to_voltha = true;
if (activated) {
start_collecting_statistics();
}
state_lock.unlock();
}
void disconnect() {
state_lock.lock();
connected_to_voltha = false;
stop_collecting_statistics();
state_lock.unlock();
}
void activate() {
state_lock.lock();
activated = true;
if (connected_to_voltha) {
start_collecting_statistics();
}
state_lock.unlock();
}
void deactivate() {
state_lock.lock();
activated = false;
stop_collecting_statistics();
state_lock.unlock();
}
}