aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/actors/core/cpu_manager.h
blob: e2e3861a3b0db66221b04246bf674f7cd7e2056d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once

#include "harmonizer.h"
#include "executor_pool.h"
#include "executor_pool_united_workers.h"
#include "balancer.h"

namespace NActors {
    struct TActorSystemSetup;

    class TCpuManager : public TNonCopyable {
        const ui32 ExecutorPoolCount;
        TArrayHolder<TAutoPtr<IExecutorPool>> Executors;
        THolder<TUnitedWorkers> UnitedWorkers;
        THolder<IBalancer> Balancer;
        THolder<IHarmonizer> Harmonizer;
        TCpuManagerConfig Config;

    public:
        explicit TCpuManager(THolder<TActorSystemSetup>& setup);

        void Setup();
        void PrepareStart(TVector<NSchedulerQueue::TReader*>& scheduleReaders, TActorSystem* actorSystem);
        void Start();
        void PrepareStop();
        void Shutdown();
        void Cleanup();

        ui32 GetExecutorsCount() const {
            return ExecutorPoolCount;
        }

        IExecutorPool* GetExecutorPool(ui32 poolId) {
            return Executors[poolId].Get();
        }

        void GetPoolStats(ui32 poolId, TExecutorPoolStats& poolStats, TVector<TExecutorThreadStats>& statsCopy) const {
            if (poolId < ExecutorPoolCount) {
                Executors[poolId]->GetCurrentStats(poolStats, statsCopy);
            }
        }

    private:
        IExecutorPool* CreateExecutorPool(ui32 poolId);
    };
}