Commit 486d7cdb authored by Georgios Bitzes's avatar Georgios Bitzes
Browse files

Allow the broadcasting of MultiOps directly from CommandMonitor

parent fb21d255
......@@ -30,14 +30,14 @@ CommandMonitor::CommandMonitor() {
}
void CommandMonitor::broadcast(const std::string& linkDescription, const RedisRequest &received) {
void CommandMonitor::broadcast(const std::string& linkDescription, const std::string& printableString) {
if(!active) return;
std::lock_guard<std::mutex> lock(mtx);
auto it = monitors.begin();
while(it != monitors.end()) {
bool stillAlive = (*it)->appendIfAttached(Formatter::status(SSTR(linkDescription << ": " << received.toPrintableString())));
bool stillAlive = (*it)->appendIfAttached(Formatter::status(SSTR(linkDescription << ": " << printableString)));
if(!stillAlive) {
it = monitors.erase(it);
......@@ -50,6 +50,16 @@ void CommandMonitor::broadcast(const std::string& linkDescription, const RedisRe
if(monitors.size() == 0) active = false;
}
void CommandMonitor::broadcast(const std::string& linkDescription, const RedisRequest& req) {
if(!active) return;
return broadcast(linkDescription, req.toPrintableString());
}
void CommandMonitor::broadcast(const std::string& linkDescription, const MultiOp& multiOp) {
if(!active) return;
return broadcast(linkDescription, multiOp.toPrintableString());
}
void CommandMonitor::addRegistration(Connection *c) {
std::lock_guard<std::mutex> lock(mtx);
......
......@@ -21,23 +21,29 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
************************************************************************/
#ifndef __QUARKDB_COMMAND_MONITOR_H__
#define __QUARKDB_COMMAND_MONITOR_H__
#ifndef QUARKDB_COMMAND_MONITOR_H
#define QUARKDB_COMMAND_MONITOR_H
#include <list>
#include "../Connection.hh"
namespace quarkdb {
class MultiOp;
class CommandMonitor {
public:
CommandMonitor();
void broadcast(const std::string& linkDescription, const RedisRequest &received);
void broadcast(const std::string& linkDescription, const RedisRequest& received);
void broadcast(const std::string& linkDescription, const MultiOp& multiOp);
void addRegistration(Connection *c);
size_t size();
private:
void broadcast(const std::string& linkDescription, const std::string& printableString);
std::atomic<int64_t> active {false};
std::mutex mtx;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment