14 MADARA_GUARD_TYPE guard(
mutex_);
52 MADARA_GUARD_TYPE guard(mutex_);
64 result =
context_->get(queue_.vector_[head], settings_);
66 head_ = increment(head, 1);
85 MADARA_GUARD_TYPE guard(mutex_);
89 this->count_.set_name(var_name +
".count",
knowledge);
90 this->head_.set_name(var_name +
".head",
knowledge);
91 this->tail_.set_name(var_name +
".tail",
knowledge);
92 this->queue_.set_name(var_name,
knowledge);
102 MADARA_GUARD_TYPE guard(mutex_);
106 this->count_.set_name(var_name +
".count",
knowledge);
107 this->head_.set_name(var_name +
".head",
knowledge);
108 this->tail_.set_name(var_name +
".tail",
knowledge);
109 this->queue_.set_name(var_name,
knowledge);
const ThreadSafeContext * context_
A thread-safe guard for a context or knowledge base.
This class provides a distributed knowledge base to users.
This class encapsulates an entry in a KnowledgeBase.
Settings for applying knowledge updates.
bool signal_changes
Toggle whether to signal changes have happened.
void signal(bool lock=true) const
Signals that this thread is done with the context.
int set(const std::string &key, T &&value, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Atomically sets the value of a variable to the specific record.
Provides an interface for external functions into the MADARA KaRL variable settings.
ThreadSafeContext * context_
Variable context that we are modifying.
bool enqueue(const knowledge::KnowledgeRecord &record)
Enqueues a record to the end of the queue.
Integer count_
Count of elements in queue.
size_t count(void)
Returns the number of records in the queue.
Integer tail_
Tail of the queue.
knowledge::KnowledgeRecord::Integer increment(knowledge::KnowledgeRecord::Integer base, knowledge::KnowledgeRecord::Integer value)
Increments the base by the value, using size as a boundary.
knowledge::KnowledgeRecord dequeue(bool wait=true)
Dequeues a record from the front of the queue.
void set_name(const std::string &var_name, KnowledgeBase &knowledge)
Sets the variable name that this refers to.
std::string name_
Prefix of variable.
MADARA_LOCK_TYPE mutex_
guard for access and changes
KnowledgeUpdateSettings settings_
Settings for modifications.
Vector queue_
Underlying array of records.
std::vector< VariableReference > vector_
Values of the array.
size_t size(void) const
Returns the size of the local vector.
Provides functions and classes for the distributed knowledge base.