cpu_manager.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #pragma once
  2. #include "harmonizer.h"
  3. #include "executor_pool.h"
  4. #include "executor_pool_united_workers.h"
  5. #include "balancer.h"
  6. namespace NActors {
  7. struct TActorSystemSetup;
  8. class TCpuManager : public TNonCopyable {
  9. const ui32 ExecutorPoolCount;
  10. TArrayHolder<TAutoPtr<IExecutorPool>> Executors;
  11. THolder<TUnitedWorkers> UnitedWorkers;
  12. THolder<IBalancer> Balancer;
  13. THolder<IHarmonizer> Harmonizer;
  14. TCpuManagerConfig Config;
  15. public:
  16. explicit TCpuManager(THolder<TActorSystemSetup>& setup);
  17. void Setup();
  18. void PrepareStart(TVector<NSchedulerQueue::TReader*>& scheduleReaders, TActorSystem* actorSystem);
  19. void Start();
  20. void PrepareStop();
  21. void Shutdown();
  22. void Cleanup();
  23. TVector<IExecutorPool*> GetBasicExecutorPools() const;
  24. ui32 GetExecutorsCount() const {
  25. return ExecutorPoolCount;
  26. }
  27. IExecutorPool* GetExecutorPool(ui32 poolId) {
  28. return Executors[poolId].Get();
  29. }
  30. void GetPoolStats(ui32 poolId, TExecutorPoolStats& poolStats, TVector<TExecutorThreadStats>& statsCopy) const {
  31. if (poolId < ExecutorPoolCount) {
  32. Executors[poolId]->GetCurrentStats(poolStats, statsCopy);
  33. }
  34. }
  35. THarmonizerStats GetHarmonizerStats() const {
  36. if (Harmonizer) {
  37. return Harmonizer->GetStats();
  38. }
  39. return {};
  40. }
  41. private:
  42. IExecutorPool* CreateExecutorPool(ui32 poolId);
  43. };
  44. }