aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/actor/queue_in_actor.h
diff options
context:
space:
mode:
authornga <nga@yandex-team.ru>2022-02-10 16:48:09 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:09 +0300
commitc2a1af049e9deca890e9923abe64fe6c59060348 (patch)
treeb222e5ac2e2e98872661c51ccceee5da0d291e13 /library/cpp/messagebus/actor/queue_in_actor.h
parent1f553f46fb4f3c5eec631352cdd900a0709016af (diff)
downloadydb-c2a1af049e9deca890e9923abe64fe6c59060348.tar.gz
Restoring authorship annotation for <nga@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/messagebus/actor/queue_in_actor.h')
-rw-r--r--library/cpp/messagebus/actor/queue_in_actor.h44
1 files changed, 22 insertions, 22 deletions
diff --git a/library/cpp/messagebus/actor/queue_in_actor.h b/library/cpp/messagebus/actor/queue_in_actor.h
index f93eb03070..9865996532 100644
--- a/library/cpp/messagebus/actor/queue_in_actor.h
+++ b/library/cpp/messagebus/actor/queue_in_actor.h
@@ -1,80 +1,80 @@
-#pragma once
-
-#include "actor.h"
-#include "queue_for_actor.h"
-
+#pragma once
+
+#include "actor.h"
+#include "queue_for_actor.h"
+
#include <functional>
-namespace NActor {
+namespace NActor {
template <typename TItem>
class IQueueInActor {
public:
virtual void EnqueueAndScheduleV(const TItem& item) = 0;
virtual void DequeueAllV() = 0;
virtual void DequeueAllLikelyEmptyV() = 0;
-
+
virtual ~IQueueInActor() {
}
};
-
+
template <typename TThis, typename TItem, typename TActorTag = TDefaultTag, typename TQueueTag = TDefaultTag>
class TQueueInActor: public IQueueInActor<TItem> {
typedef TQueueInActor<TThis, TItem, TActorTag, TQueueTag> TSelf;
-
+
public:
// TODO: make protected
TQueueForActor<TItem> QueueInActor;
-
+
private:
TActor<TThis, TActorTag>* GetActor() {
return GetThis();
}
-
+
TThis* GetThis() {
return static_cast<TThis*>(this);
}
-
+
void ProcessItem(const TItem& item) {
GetThis()->ProcessItem(TActorTag(), TQueueTag(), item);
}
-
+
public:
void EnqueueAndNoSchedule(const TItem& item) {
QueueInActor.Enqueue(item);
}
-
+
void EnqueueAndSchedule(const TItem& item) {
EnqueueAndNoSchedule(item);
GetActor()->Schedule();
}
-
+
void EnqueueAndScheduleV(const TItem& item) override {
EnqueueAndSchedule(item);
}
-
+
void Clear() {
QueueInActor.Clear();
}
-
+
void DequeueAll() {
QueueInActor.DequeueAll(std::bind(&TSelf::ProcessItem, this, std::placeholders::_1));
}
-
+
void DequeueAllV() override {
return DequeueAll();
}
-
+
void DequeueAllLikelyEmpty() {
QueueInActor.DequeueAllLikelyEmpty(std::bind(&TSelf::ProcessItem, this, std::placeholders::_1));
}
-
+
void DequeueAllLikelyEmptyV() override {
return DequeueAllLikelyEmpty();
}
-
+
bool IsEmpty() {
return QueueInActor.IsEmpty();
}
};
-
+
}