blob: 454035477b80830a5a78703449fea0a4366b2430 (
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
47
48
49
50
51
52
53
54
55
56
57
|
#pragma once
#include "actorsystem.h"
#include "executor_pool_basic.h"
#include "executor_pool_io.h"
#include "executor_pool_united.h"
namespace NActors {
class TCpuManager : public TNonCopyable {
const ui32 ExecutorPoolCount;
TArrayHolder<TAutoPtr<IExecutorPool>> Executors;
THolder<TUnitedWorkers> UnitedWorkers;
THolder<IBalancer> Balancer;
TCpuManagerConfig Config;
public:
explicit TCpuManager(THolder<TActorSystemSetup>& setup)
: ExecutorPoolCount(setup->GetExecutorsCount())
, Balancer(setup->Balancer)
, Config(setup->CpuManager)
{
if (setup->Executors) { // Explicit mode w/o united pools
Executors.Reset(setup->Executors.Release());
for (ui32 excIdx = 0; excIdx != ExecutorPoolCount; ++excIdx) {
IExecutorPool* pool = Executors[excIdx].Get();
Y_VERIFY(dynamic_cast<TUnitedExecutorPool*>(pool) == nullptr,
"united executor pool is prohibited in explicit mode of NActors::TCpuManager");
}
} else {
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);
};
}
|