diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/messagebus/actor/executor.h | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/messagebus/actor/executor.h')
-rw-r--r-- | library/cpp/messagebus/actor/executor.h | 130 |
1 files changed, 65 insertions, 65 deletions
diff --git a/library/cpp/messagebus/actor/executor.h b/library/cpp/messagebus/actor/executor.h index 7292d8be53..4b9bcb1da0 100644 --- a/library/cpp/messagebus/actor/executor.h +++ b/library/cpp/messagebus/actor/executor.h @@ -11,95 +11,95 @@ #include <util/thread/lfqueue.h> namespace NActor { - namespace NPrivate { - struct TExecutorHistory { - struct THistoryRecord { - ui32 MaxQueueSize; - }; - TVector<THistoryRecord> HistoryRecords; - ui64 LastHistoryRecordSecond; - - ui64 FirstHistoryRecordSecond() const { - return LastHistoryRecordSecond - HistoryRecords.size() + 1; - } + namespace NPrivate { + struct TExecutorHistory { + struct THistoryRecord { + ui32 MaxQueueSize; + }; + TVector<THistoryRecord> HistoryRecords; + ui64 LastHistoryRecordSecond; + + ui64 FirstHistoryRecordSecond() const { + return LastHistoryRecordSecond - HistoryRecords.size() + 1; + } + }; + + struct TExecutorStatus { + size_t WorkQueueSize = 0; + TExecutorHistory History; + TString Status; }; + } - struct TExecutorStatus { - size_t WorkQueueSize = 0; - TExecutorHistory History; - TString Status; - }; - } - - class IWorkItem { - public: - virtual ~IWorkItem() { + class IWorkItem { + public: + virtual ~IWorkItem() { } - virtual void DoWork(/* must release this */) = 0; + virtual void DoWork(/* must release this */) = 0; }; - struct TExecutorWorker; + struct TExecutorWorker; - class TExecutor: public TAtomicRefCount<TExecutor> { - friend struct TExecutorWorker; + class TExecutor: public TAtomicRefCount<TExecutor> { + friend struct TExecutorWorker; - public: - struct TConfig { - size_t WorkerCount; - const char* Name; + public: + struct TConfig { + size_t WorkerCount; + const char* Name; - TConfig() - : WorkerCount(1) - , Name() - { - } - }; + TConfig() + : WorkerCount(1) + , Name() + { + } + }; - private: - struct TImpl; - THolder<TImpl> Impl; + private: + struct TImpl; + THolder<TImpl> Impl; - const TConfig Config; + const TConfig Config; - TAtomic ExitWorkers; + TAtomic ExitWorkers; - TVector<TAutoPtr<TExecutorWorker>> WorkerThreads; + TVector<TAutoPtr<TExecutorWorker>> WorkerThreads; - TRingBufferWithSpinLock<IWorkItem*> WorkItems; + TRingBufferWithSpinLock<IWorkItem*> WorkItems; - TMutex WorkMutex; - TCondVar WorkAvailable; + TMutex WorkMutex; + TCondVar WorkAvailable; - public: - explicit TExecutor(size_t workerCount); - TExecutor(const TConfig& config); - ~TExecutor(); + public: + explicit TExecutor(size_t workerCount); + TExecutor(const TConfig& config); + ~TExecutor(); - void Stop(); + void Stop(); - void EnqueueWork(TArrayRef<IWorkItem* const> w); + void EnqueueWork(TArrayRef<IWorkItem* const> w); - size_t GetWorkQueueSize() const; - TString GetStatus() const; - TString GetStatusSingleLine() const; - NPrivate::TExecutorStatus GetStatusRecordInternal() const; + size_t GetWorkQueueSize() const; + TString GetStatus() const; + TString GetStatusSingleLine() const; + NPrivate::TExecutorStatus GetStatusRecordInternal() const; - bool IsInExecutorThread() const; + bool IsInExecutorThread() const; - private: - void Init(); + private: + void Init(); - TAutoPtr<IWorkItem> DequeueWork(); + TAutoPtr<IWorkItem> DequeueWork(); - void ProcessWorkQueueHere(); + void ProcessWorkQueueHere(); - inline void RunWorkItem(TAutoPtr<IWorkItem>); + inline void RunWorkItem(TAutoPtr<IWorkItem>); - void RunWorker(); + void RunWorker(); - ui32 GetMaxQueueSizeAndClear() const; - }; + ui32 GetMaxQueueSizeAndClear() const; + }; - using TExecutorPtr = TIntrusivePtr<TExecutor>; + using TExecutorPtr = TIntrusivePtr<TExecutor>; -} +} |