summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/hle/kernel/k_light_condition_variable.h21
-rw-r--r--src/core/hle/kernel/k_resource_limit.cpp2
-rw-r--r--src/core/hle/kernel/k_resource_limit.h11
3 files changed, 15 insertions, 19 deletions
diff --git a/src/core/hle/kernel/k_light_condition_variable.h b/src/core/hle/kernel/k_light_condition_variable.h
index 26573a239..26d94d7c0 100644
--- a/src/core/hle/kernel/k_light_condition_variable.h
+++ b/src/core/hle/kernel/k_light_condition_variable.h
@@ -17,44 +17,41 @@ namespace Kernel {
17class KernelCore; 17class KernelCore;
18 18
19class KLightConditionVariable { 19class KLightConditionVariable {
20private:
21 KThreadQueue m_thread_queue;
22
23public: 20public:
24 KLightConditionVariable(KernelCore& kernel) : m_thread_queue(kernel), kernel(kernel) {} 21 explicit KLightConditionVariable(KernelCore& kernel) : thread_queue(kernel), kernel(kernel) {}
25 22
26 void Wait(KLightLock* lock, s64 timeout = -1ll) { 23 void Wait(KLightLock* lock, s64 timeout = -1) {
27 WaitImpl(lock, timeout); 24 WaitImpl(lock, timeout);
28 lock->Lock(); 25 lock->Lock();
29 } 26 }
30 27
31 void Broadcast() { 28 void Broadcast() {
32 KScopedSchedulerLock lk{kernel}; 29 KScopedSchedulerLock lk{kernel};
33 while (m_thread_queue.WakeupFrontThread() != nullptr) { 30 while (thread_queue.WakeupFrontThread() != nullptr) {
34 /* We want to signal all threads, and so should continue waking up until there's nothing 31 // We want to signal all threads, and so should continue waking up until there's nothing
35 * to wake. */ 32 // to wake.
36 } 33 }
37 } 34 }
38 35
39private: 36private:
40 void WaitImpl(KLightLock* lock, s64 timeout) { 37 void WaitImpl(KLightLock* lock, s64 timeout) {
41 KThread* owner = GetCurrentThreadPointer(kernel); 38 KThread* owner = GetCurrentThreadPointer(kernel);
42 // KHardwareTimer* timer;
43 39
44 /* Sleep the thread. */ 40 // Sleep the thread.
45 { 41 {
46 KScopedSchedulerLockAndSleep lk(kernel, owner, timeout); 42 KScopedSchedulerLockAndSleep lk(kernel, owner, timeout);
47 lock->Unlock(); 43 lock->Unlock();
48 44
49 if (!m_thread_queue.SleepThread(owner)) { 45 if (!thread_queue.SleepThread(owner)) {
50 lk.CancelSleep(); 46 lk.CancelSleep();
51 return; 47 return;
52 } 48 }
53 } 49 }
54 50
55 /* Cancel the task that the sleep setup. */ 51 // Cancel the task that the sleep setup.
56 kernel.TimeManager().UnscheduleTimeEvent(owner); 52 kernel.TimeManager().UnscheduleTimeEvent(owner);
57 } 53 }
58 KernelCore& kernel; 54 KernelCore& kernel;
55 KThreadQueue thread_queue;
59}; 56};
60} // namespace Kernel 57} // namespace Kernel
diff --git a/src/core/hle/kernel/k_resource_limit.cpp b/src/core/hle/kernel/k_resource_limit.cpp
index 3cee8d0f7..ab2ab683f 100644
--- a/src/core/hle/kernel/k_resource_limit.cpp
+++ b/src/core/hle/kernel/k_resource_limit.cpp
@@ -13,9 +13,7 @@
13#include "core/hle/kernel/svc_results.h" 13#include "core/hle/kernel/svc_results.h"
14 14
15namespace Kernel { 15namespace Kernel {
16namespace {
17constexpr s64 DefaultTimeout = 10000000000; // 10 seconds 16constexpr s64 DefaultTimeout = 10000000000; // 10 seconds
18}
19 17
20KResourceLimit::KResourceLimit(KernelCore& kernel, Core::System& system) 18KResourceLimit::KResourceLimit(KernelCore& kernel, Core::System& system)
21 : Object{kernel}, lock{kernel}, cond_var{kernel}, kernel{kernel}, system(system) {} 19 : Object{kernel}, lock{kernel}, cond_var{kernel}, kernel{kernel}, system(system) {}
diff --git a/src/core/hle/kernel/k_resource_limit.h b/src/core/hle/kernel/k_resource_limit.h
index 5f916c99c..6b3437ea6 100644
--- a/src/core/hle/kernel/k_resource_limit.h
+++ b/src/core/hle/kernel/k_resource_limit.h
@@ -37,7 +37,7 @@ constexpr bool IsValidResourceType(LimitableResource type) {
37 37
38class KResourceLimit final : public Object { 38class KResourceLimit final : public Object {
39public: 39public:
40 KResourceLimit(KernelCore& kernel, Core::System& system); 40 explicit KResourceLimit(KernelCore& kernel, Core::System& system);
41 ~KResourceLimit(); 41 ~KResourceLimit();
42 42
43 s64 GetLimitValue(LimitableResource which) const; 43 s64 GetLimitValue(LimitableResource which) const;
@@ -67,10 +67,11 @@ public:
67 virtual void Finalize() override {} 67 virtual void Finalize() override {}
68 68
69private: 69private:
70 std::array<s64, static_cast<std::size_t>(LimitableResource::Count)> limit_values{}; 70 using ResourceArray = std::array<s64, static_cast<std::size_t>(LimitableResource::Count)>;
71 std::array<s64, static_cast<std::size_t>(LimitableResource::Count)> current_values{}; 71 ResourceArray limit_values{};
72 std::array<s64, static_cast<std::size_t>(LimitableResource::Count)> current_hints{}; 72 ResourceArray current_values{};
73 std::array<s64, static_cast<std::size_t>(LimitableResource::Count)> peak_values{}; 73 ResourceArray current_hints{};
74 ResourceArray peak_values{};
74 mutable KLightLock lock; 75 mutable KLightLock lock;
75 s32 waiter_count{}; 76 s32 waiter_count{};
76 KLightConditionVariable cond_var; 77 KLightConditionVariable cond_var;