aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/scheduler_actor.h
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/messagebus/scheduler_actor.h
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/messagebus/scheduler_actor.h')
-rw-r--r--library/cpp/messagebus/scheduler_actor.h132
1 files changed, 66 insertions, 66 deletions
diff --git a/library/cpp/messagebus/scheduler_actor.h b/library/cpp/messagebus/scheduler_actor.h
index d0c23c94c4..4176ea45a9 100644
--- a/library/cpp/messagebus/scheduler_actor.h
+++ b/library/cpp/messagebus/scheduler_actor.h
@@ -8,78 +8,78 @@
#include <util/system/mutex.h>
-namespace NBus {
- namespace NPrivate {
- template <typename TThis, typename TTag = NActor::TDefaultTag>
- class TScheduleActor {
- typedef NActor::TActor<TThis, TTag> TActorForMe;
-
- private:
- TScheduler* const Scheduler;
-
- TMutex Mutex;
-
- TInstant ScheduleTime;
-
- public:
- TLocalTasks Alarm;
-
- private:
- struct TScheduleItemImpl: public IScheduleItem {
- TIntrusivePtr<TThis> Thiz;
-
- TScheduleItemImpl(TIntrusivePtr<TThis> thiz, TInstant when)
- : IScheduleItem(when)
- , Thiz(thiz)
- {
- }
-
- void Do() override {
- {
- TWhatThreadDoesAcquireGuard<TMutex> guard(Thiz->Mutex, "scheduler actor: acquiring lock for Do");
-
- if (Thiz->ScheduleTime == TInstant::Max()) {
- // was already fired
- return;
- }
-
- Thiz->ScheduleTime = TInstant::Max();
- }
-
- Thiz->Alarm.AddTask();
- Thiz->GetActorForMe()->Schedule();
- }
- };
-
- public:
- TScheduleActor(TScheduler* scheduler)
- : Scheduler(scheduler)
- , ScheduleTime(TInstant::Max())
+namespace NBus {
+ namespace NPrivate {
+ template <typename TThis, typename TTag = NActor::TDefaultTag>
+ class TScheduleActor {
+ typedef NActor::TActor<TThis, TTag> TActorForMe;
+
+ private:
+ TScheduler* const Scheduler;
+
+ TMutex Mutex;
+
+ TInstant ScheduleTime;
+
+ public:
+ TLocalTasks Alarm;
+
+ private:
+ struct TScheduleItemImpl: public IScheduleItem {
+ TIntrusivePtr<TThis> Thiz;
+
+ TScheduleItemImpl(TIntrusivePtr<TThis> thiz, TInstant when)
+ : IScheduleItem(when)
+ , Thiz(thiz)
+ {
+ }
+
+ void Do() override {
+ {
+ TWhatThreadDoesAcquireGuard<TMutex> guard(Thiz->Mutex, "scheduler actor: acquiring lock for Do");
+
+ if (Thiz->ScheduleTime == TInstant::Max()) {
+ // was already fired
+ return;
+ }
+
+ Thiz->ScheduleTime = TInstant::Max();
+ }
+
+ Thiz->Alarm.AddTask();
+ Thiz->GetActorForMe()->Schedule();
+ }
+ };
+
+ public:
+ TScheduleActor(TScheduler* scheduler)
+ : Scheduler(scheduler)
+ , ScheduleTime(TInstant::Max())
{
- }
-
- /// call Act(TTag) at specified time, unless it is already scheduled at earlier time.
- void ScheduleAt(TInstant when) {
- TWhatThreadDoesAcquireGuard<TMutex> guard(Mutex, "scheduler: acquiring lock for ScheduleAt");
-
- if (when > ScheduleTime) {
- // already scheduled
+ }
+
+ /// call Act(TTag) at specified time, unless it is already scheduled at earlier time.
+ void ScheduleAt(TInstant when) {
+ TWhatThreadDoesAcquireGuard<TMutex> guard(Mutex, "scheduler: acquiring lock for ScheduleAt");
+
+ if (when > ScheduleTime) {
+ // already scheduled
return;
}
- ScheduleTime = when;
- Scheduler->Schedule(new TScheduleItemImpl(GetThis(), when));
+ ScheduleTime = when;
+ Scheduler->Schedule(new TScheduleItemImpl(GetThis(), when));
}
- private:
- TThis* GetThis() {
- return static_cast<TThis*>(this);
- }
+ private:
+ TThis* GetThis() {
+ return static_cast<TThis*>(this);
+ }
- TActorForMe* GetActorForMe() {
- return static_cast<TActorForMe*>(GetThis());
- }
- };
+ TActorForMe* GetActorForMe() {
+ return static_cast<TActorForMe*>(GetThis());
+ }
+ };
}
-}
+}