Skip to content
Snippets Groups Projects
Commit 1e10fc64 authored by Eric Cano's avatar Eric Cano
Browse files

Various debugging, plus changed the end criterion for the main process: now counter based.

parent 77036767
No related branches found
No related tags found
No related merge requests found
#pragma once
#include "ObjectOps.hpp"
#include "objectstore/cta.pb.h"
namespace cta { namespace objectstore {
class Counter: private ObjectOps<serializers::Counter> {
public:
Counter(const std::string & name, Agent & agent):
ObjectOps<serializers::Counter>(agent.objectStore(), name)
{
// check the presence of the entry
serializers::Counter cs;
updateFromObjectStore(cs, agent.getFreeContext());
}
void inc(Agent & agent) {
serializers::Counter cs;
ContextHandle & ctx = agent.getFreeContext();
lockExclusiveAndRead(cs, ctx, __func__);
cs.set_count(cs.count()+1);
unlock(ctx, __func__);
}
uint64_t get(Agent & agent) {
serializers::Counter cs;
updateFromObjectStore(cs, agent.getFreeContext());
return cs.count();
}
};
}}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment