aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/scheduler_actor.h
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:17 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:17 +0300
commitd3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch)
treedd4bd3ca0f36b817e96812825ffaf10d645803f2 /library/cpp/messagebus/scheduler_actor.h
parent72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff)
downloadydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 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 4176ea45a9..d0c23c94c4 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());
+ }
+ };
}
-}
+}