summaryrefslogtreecommitdiffstats
path: root/src/core/cpu_manager.h
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2020-02-25 03:04:12 +0100
committerFernando Sahmkow <fsahmkow27@gmail.com>2020-06-27 17:35:06 +0200
commite31425df3877636c098ec7426ebd2067920715cb (patch)
tree5c0fc518a4ebb8413c491b43a9fdd99450c7bd80 /src/core/cpu_manager.h
parentMerge pull request #3396 from FernandoS27/prometheus-1 (diff)
downloadyuzu-e31425df3877636c098ec7426ebd2067920715cb.tar
yuzu-e31425df3877636c098ec7426ebd2067920715cb.tar.gz
yuzu-e31425df3877636c098ec7426ebd2067920715cb.tar.bz2
yuzu-e31425df3877636c098ec7426ebd2067920715cb.tar.lz
yuzu-e31425df3877636c098ec7426ebd2067920715cb.tar.xz
yuzu-e31425df3877636c098ec7426ebd2067920715cb.tar.zst
yuzu-e31425df3877636c098ec7426ebd2067920715cb.zip
Diffstat (limited to '')
-rw-r--r--src/core/cpu_manager.h49
1 files changed, 37 insertions, 12 deletions
diff --git a/src/core/cpu_manager.h b/src/core/cpu_manager.h
index 97554d1bb..8103ae857 100644
--- a/src/core/cpu_manager.h
+++ b/src/core/cpu_manager.h
@@ -5,12 +5,18 @@
#pragma once
#include <array>
+#include <functional>
#include <memory>
+#include <thread>
#include "core/hardware_properties.h"
+namespace Common {
+class Event;
+class Fiber;
+} // namespace Common
+
namespace Core {
-class CoreManager;
class System;
class CpuManager {
@@ -27,21 +33,40 @@ public:
void Initialize();
void Shutdown();
- CoreManager& GetCoreManager(std::size_t index);
- const CoreManager& GetCoreManager(std::size_t index) const;
+ void Pause(bool paused);
+
+ std::function<void(void*)> GetGuestThreadStartFunc();
+ std::function<void(void*)> GetIdleThreadStartFunc();
+ std::function<void(void*)> GetSuspendThreadStartFunc();
+ void* GetStartFuncParamater();
- CoreManager& GetCurrentCoreManager();
- const CoreManager& GetCurrentCoreManager() const;
+private:
+ static void GuestThreadFunction(void* cpu_manager);
+ static void IdleThreadFunction(void* cpu_manager);
+ static void SuspendThreadFunction(void* cpu_manager);
- std::size_t GetActiveCoreIndex() const {
- return active_core;
- }
+ void RunGuestThread();
+ void RunIdleThread();
+ void RunSuspendThread();
- void RunLoop(bool tight_loop);
+ static void ThreadStart(CpuManager& cpu_manager, std::size_t core);
-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
+ void RunThread(std::size_t core);
+
+ struct CoreData {
+ std::shared_ptr<Common::Fiber> host_context;
+ std::unique_ptr<Common::Event> enter_barrier;
+ std::unique_ptr<Common::Event> exit_barrier;
+ std::atomic<bool> is_running;
+ std::atomic<bool> is_paused;
+ std::atomic<bool> initialized;
+ std::unique_ptr<std::thread> host_thread;
+ };
+
+ std::atomic<bool> running_mode{};
+ std::atomic<bool> paused_state{};
+
+ std::array<CoreData, Core::Hardware::NUM_CPU_CORES> core_data{};
System& system;
};