diff options
| author | 2022-07-02 12:33:49 -0400 | |
|---|---|---|
| committer | 2022-07-02 12:33:49 -0400 | |
| commit | ed0319cfed2c99e6366aaf725d96bb28a9332e4d (patch) | |
| tree | 1598e6d320005e0d177106e28ebc6728234f1f24 /src/core/cpu_manager.cpp | |
| parent | Merge pull request #7454 from FernandoS27/new-core-timing (diff) | |
| download | yuzu-ed0319cfed2c99e6366aaf725d96bb28a9332e4d.tar.gz yuzu-ed0319cfed2c99e6366aaf725d96bb28a9332e4d.tar.xz yuzu-ed0319cfed2c99e6366aaf725d96bb28a9332e4d.zip | |
common/fiber: make fibers easier to use
Diffstat (limited to 'src/core/cpu_manager.cpp')
| -rw-r--r-- | src/core/cpu_manager.cpp | 51 |
1 files changed, 16 insertions, 35 deletions
diff --git a/src/core/cpu_manager.cpp b/src/core/cpu_manager.cpp index fd6928105..f184b904b 100644 --- a/src/core/cpu_manager.cpp +++ b/src/core/cpu_manager.cpp | |||
| @@ -41,51 +41,32 @@ void CpuManager::Shutdown() { | |||
| 41 | } | 41 | } |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | std::function<void(void*)> CpuManager::GetGuestThreadStartFunc() { | 44 | void CpuManager::GuestThreadFunction() { |
| 45 | return GuestThreadFunction; | 45 | if (is_multicore) { |
| 46 | } | 46 | MultiCoreRunGuestThread(); |
| 47 | |||
| 48 | std::function<void(void*)> CpuManager::GetIdleThreadStartFunc() { | ||
| 49 | return IdleThreadFunction; | ||
| 50 | } | ||
| 51 | |||
| 52 | std::function<void(void*)> CpuManager::GetShutdownThreadStartFunc() { | ||
| 53 | return ShutdownThreadFunction; | ||
| 54 | } | ||
| 55 | |||
| 56 | void CpuManager::GuestThreadFunction(void* cpu_manager_) { | ||
| 57 | CpuManager* cpu_manager = static_cast<CpuManager*>(cpu_manager_); | ||
| 58 | if (cpu_manager->is_multicore) { | ||
| 59 | cpu_manager->MultiCoreRunGuestThread(); | ||
| 60 | } else { | 47 | } else { |
| 61 | cpu_manager->SingleCoreRunGuestThread(); | 48 | SingleCoreRunGuestThread(); |
| 62 | } | 49 | } |
| 63 | } | 50 | } |
| 64 | 51 | ||
| 65 | void CpuManager::GuestRewindFunction(void* cpu_manager_) { | 52 | void CpuManager::GuestRewindFunction() { |
| 66 | CpuManager* cpu_manager = static_cast<CpuManager*>(cpu_manager_); | 53 | if (is_multicore) { |
| 67 | if (cpu_manager->is_multicore) { | 54 | MultiCoreRunGuestLoop(); |
| 68 | cpu_manager->MultiCoreRunGuestLoop(); | ||
| 69 | } else { | 55 | } else { |
| 70 | cpu_manager->SingleCoreRunGuestLoop(); | 56 | SingleCoreRunGuestLoop(); |
| 71 | } | 57 | } |
| 72 | } | 58 | } |
| 73 | 59 | ||
| 74 | void CpuManager::IdleThreadFunction(void* cpu_manager_) { | 60 | void CpuManager::IdleThreadFunction() { |
| 75 | CpuManager* cpu_manager = static_cast<CpuManager*>(cpu_manager_); | 61 | if (is_multicore) { |
| 76 | if (cpu_manager->is_multicore) { | 62 | MultiCoreRunIdleThread(); |
| 77 | cpu_manager->MultiCoreRunIdleThread(); | ||
| 78 | } else { | 63 | } else { |
| 79 | cpu_manager->SingleCoreRunIdleThread(); | 64 | SingleCoreRunIdleThread(); |
| 80 | } | 65 | } |
| 81 | } | 66 | } |
| 82 | 67 | ||
| 83 | void CpuManager::ShutdownThreadFunction(void* cpu_manager) { | 68 | void CpuManager::ShutdownThreadFunction() { |
| 84 | static_cast<CpuManager*>(cpu_manager)->ShutdownThread(); | 69 | ShutdownThread(); |
| 85 | } | ||
| 86 | |||
| 87 | void* CpuManager::GetStartFuncParameter() { | ||
| 88 | return this; | ||
| 89 | } | 70 | } |
| 90 | 71 | ||
| 91 | /////////////////////////////////////////////////////////////////////////////// | 72 | /////////////////////////////////////////////////////////////////////////////// |
| @@ -97,7 +78,7 @@ void CpuManager::MultiCoreRunGuestThread() { | |||
| 97 | kernel.CurrentScheduler()->OnThreadStart(); | 78 | kernel.CurrentScheduler()->OnThreadStart(); |
| 98 | auto* thread = kernel.CurrentScheduler()->GetSchedulerCurrentThread(); | 79 | auto* thread = kernel.CurrentScheduler()->GetSchedulerCurrentThread(); |
| 99 | auto& host_context = thread->GetHostContext(); | 80 | auto& host_context = thread->GetHostContext(); |
| 100 | host_context->SetRewindPoint(GuestRewindFunction, this); | 81 | host_context->SetRewindPoint([this] { GuestRewindFunction(); }); |
| 101 | MultiCoreRunGuestLoop(); | 82 | MultiCoreRunGuestLoop(); |
| 102 | } | 83 | } |
| 103 | 84 | ||
| @@ -134,7 +115,7 @@ void CpuManager::SingleCoreRunGuestThread() { | |||
| 134 | kernel.CurrentScheduler()->OnThreadStart(); | 115 | kernel.CurrentScheduler()->OnThreadStart(); |
| 135 | auto* thread = kernel.CurrentScheduler()->GetSchedulerCurrentThread(); | 116 | auto* thread = kernel.CurrentScheduler()->GetSchedulerCurrentThread(); |
| 136 | auto& host_context = thread->GetHostContext(); | 117 | auto& host_context = thread->GetHostContext(); |
| 137 | host_context->SetRewindPoint(GuestRewindFunction, this); | 118 | host_context->SetRewindPoint([this] { GuestRewindFunction(); }); |
| 138 | SingleCoreRunGuestLoop(); | 119 | SingleCoreRunGuestLoop(); |
| 139 | } | 120 | } |
| 140 | 121 | ||