summaryrefslogtreecommitdiffstats
path: root/src/core/cpu_manager.h
blob: 97554d1bb692058d3549976d0b8a37049e850bf6 (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
// Copyright 2018 yuzu emulator team
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

#pragma once

#include <array>
#include <memory>
#include "core/hardware_properties.h"

namespace Core {

class CoreManager;
class System;

class CpuManager {
public:
    explicit CpuManager(System& system);
    CpuManager(const CpuManager&) = delete;
    CpuManager(CpuManager&&) = delete;

    ~CpuManager();

    CpuManager& operator=(const CpuManager&) = delete;
    CpuManager& operator=(CpuManager&&) = delete;

    void Initialize();
    void Shutdown();

    CoreManager& GetCoreManager(std::size_t index);
    const CoreManager& GetCoreManager(std::size_t index) const;

    CoreManager& GetCurrentCoreManager();
    const CoreManager& GetCurrentCoreManager() const;

    std::size_t GetActiveCoreIndex() const {
        return active_core;
    }

    void RunLoop(bool tight_loop);

private:
    std::array<std::unique_ptr<CoreManager>, Hardware::NUM_CPU_CORES> core_managers;
    std::size_t active_core{}; ///< Active core, only used in single thread mode

    System& system;
};

} // namespace Core