diff options
| -rw-r--r-- | src/core/hle/kernel/k_resource_limit.cpp | 16 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_resource_limit.h | 2 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/core/hle/kernel/k_resource_limit.cpp b/src/core/hle/kernel/k_resource_limit.cpp index b3076b030..65c30e9b3 100644 --- a/src/core/hle/kernel/k_resource_limit.cpp +++ b/src/core/hle/kernel/k_resource_limit.cpp | |||
| @@ -18,14 +18,14 @@ constexpr s64 DefaultTimeout = 10000000000; // 10 seconds | |||
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | KResourceLimit::KResourceLimit(KernelCore& kernel, Core::System& system) | 20 | KResourceLimit::KResourceLimit(KernelCore& kernel, Core::System& system) |
| 21 | : Object{kernel}, m_lock{kernel}, cond_var{kernel}, kernel{kernel}, system(system) {} | 21 | : Object{kernel}, lock{kernel}, cond_var{kernel}, kernel{kernel}, system(system) {} |
| 22 | KResourceLimit::~KResourceLimit() = default; | 22 | KResourceLimit::~KResourceLimit() = default; |
| 23 | 23 | ||
| 24 | s64 KResourceLimit::GetLimitValue(LimitableResource which) const { | 24 | s64 KResourceLimit::GetLimitValue(LimitableResource which) const { |
| 25 | const auto index = static_cast<std::size_t>(which); | 25 | const auto index = static_cast<std::size_t>(which); |
| 26 | s64 value{}; | 26 | s64 value{}; |
| 27 | { | 27 | { |
| 28 | KScopedLightLock lk{m_lock}; | 28 | KScopedLightLock lk{lock}; |
| 29 | value = limit_values[index]; | 29 | value = limit_values[index]; |
| 30 | ASSERT(value >= 0); | 30 | ASSERT(value >= 0); |
| 31 | ASSERT(current_values[index] <= limit_values[index]); | 31 | ASSERT(current_values[index] <= limit_values[index]); |
| @@ -51,7 +51,7 @@ s64 KResourceLimit::GetPeakValue(LimitableResource which) const { | |||
| 51 | const auto index = static_cast<std::size_t>(which); | 51 | const auto index = static_cast<std::size_t>(which); |
| 52 | s64 value{}; | 52 | s64 value{}; |
| 53 | { | 53 | { |
| 54 | KScopedLightLock lk{m_lock}; | 54 | KScopedLightLock lk{lock}; |
| 55 | value = peak_values[index]; | 55 | value = peak_values[index]; |
| 56 | ASSERT(value >= 0); | 56 | ASSERT(value >= 0); |
| 57 | ASSERT(current_values[index] <= limit_values[index]); | 57 | ASSERT(current_values[index] <= limit_values[index]); |
| @@ -64,7 +64,7 @@ s64 KResourceLimit::GetFreeValue(LimitableResource which) const { | |||
| 64 | const auto index = static_cast<std::size_t>(which); | 64 | const auto index = static_cast<std::size_t>(which); |
| 65 | s64 value{}; | 65 | s64 value{}; |
| 66 | { | 66 | { |
| 67 | KScopedLightLock lk(m_lock); | 67 | KScopedLightLock lk(lock); |
| 68 | ASSERT(current_values[index] >= 0); | 68 | ASSERT(current_values[index] >= 0); |
| 69 | ASSERT(current_values[index] <= limit_values[index]); | 69 | ASSERT(current_values[index] <= limit_values[index]); |
| 70 | ASSERT(current_hints[index] <= current_values[index]); | 70 | ASSERT(current_hints[index] <= current_values[index]); |
| @@ -76,7 +76,7 @@ s64 KResourceLimit::GetFreeValue(LimitableResource which) const { | |||
| 76 | 76 | ||
| 77 | ResultCode KResourceLimit::SetLimitValue(LimitableResource which, s64 value) { | 77 | ResultCode KResourceLimit::SetLimitValue(LimitableResource which, s64 value) { |
| 78 | const auto index = static_cast<std::size_t>(which); | 78 | const auto index = static_cast<std::size_t>(which); |
| 79 | KScopedLightLock lk(m_lock); | 79 | KScopedLightLock lk(lock); |
| 80 | R_UNLESS(current_values[index] <= value, Svc::ResultInvalidState); | 80 | R_UNLESS(current_values[index] <= value, Svc::ResultInvalidState); |
| 81 | 81 | ||
| 82 | limit_values[index] = value; | 82 | limit_values[index] = value; |
| @@ -91,7 +91,7 @@ bool KResourceLimit::Reserve(LimitableResource which, s64 value) { | |||
| 91 | bool KResourceLimit::Reserve(LimitableResource which, s64 value, s64 timeout) { | 91 | bool KResourceLimit::Reserve(LimitableResource which, s64 value, s64 timeout) { |
| 92 | ASSERT(value >= 0); | 92 | ASSERT(value >= 0); |
| 93 | const auto index = static_cast<std::size_t>(which); | 93 | const auto index = static_cast<std::size_t>(which); |
| 94 | KScopedLightLock lk(m_lock); | 94 | KScopedLightLock lk(lock); |
| 95 | 95 | ||
| 96 | ASSERT(current_hints[index] <= current_values[index]); | 96 | ASSERT(current_hints[index] <= current_values[index]); |
| 97 | if (current_hints[index] >= limit_values[index]) { | 97 | if (current_hints[index] >= limit_values[index]) { |
| @@ -118,7 +118,7 @@ bool KResourceLimit::Reserve(LimitableResource which, s64 value, s64 timeout) { | |||
| 118 | if (current_hints[index] + value <= limit_values[index] && | 118 | if (current_hints[index] + value <= limit_values[index] && |
| 119 | (timeout < 0 || system.CoreTiming().GetGlobalTimeNs().count() < timeout)) { | 119 | (timeout < 0 || system.CoreTiming().GetGlobalTimeNs().count() < timeout)) { |
| 120 | waiter_count++; | 120 | waiter_count++; |
| 121 | cond_var.Wait(&m_lock, timeout); | 121 | cond_var.Wait(&lock, timeout); |
| 122 | waiter_count--; | 122 | waiter_count--; |
| 123 | } else { | 123 | } else { |
| 124 | break; | 124 | break; |
| @@ -137,7 +137,7 @@ void KResourceLimit::Release(LimitableResource which, s64 value, s64 hint) { | |||
| 137 | ASSERT(hint >= 0); | 137 | ASSERT(hint >= 0); |
| 138 | 138 | ||
| 139 | const auto index = static_cast<std::size_t>(which); | 139 | const auto index = static_cast<std::size_t>(which); |
| 140 | KScopedLightLock lk(m_lock); | 140 | KScopedLightLock lk(lock); |
| 141 | ASSERT(current_values[index] <= limit_values[index]); | 141 | ASSERT(current_values[index] <= limit_values[index]); |
| 142 | ASSERT(current_hints[index] <= current_values[index]); | 142 | ASSERT(current_hints[index] <= current_values[index]); |
| 143 | ASSERT(value <= current_values[index]); | 143 | ASSERT(value <= current_values[index]); |
diff --git a/src/core/hle/kernel/k_resource_limit.h b/src/core/hle/kernel/k_resource_limit.h index 84c59177c..5f916c99c 100644 --- a/src/core/hle/kernel/k_resource_limit.h +++ b/src/core/hle/kernel/k_resource_limit.h | |||
| @@ -71,7 +71,7 @@ private: | |||
| 71 | std::array<s64, static_cast<std::size_t>(LimitableResource::Count)> current_values{}; | 71 | std::array<s64, static_cast<std::size_t>(LimitableResource::Count)> current_values{}; |
| 72 | std::array<s64, static_cast<std::size_t>(LimitableResource::Count)> current_hints{}; | 72 | std::array<s64, static_cast<std::size_t>(LimitableResource::Count)> current_hints{}; |
| 73 | std::array<s64, static_cast<std::size_t>(LimitableResource::Count)> peak_values{}; | 73 | std::array<s64, static_cast<std::size_t>(LimitableResource::Count)> peak_values{}; |
| 74 | mutable KLightLock m_lock; | 74 | mutable KLightLock lock; |
| 75 | s32 waiter_count{}; | 75 | s32 waiter_count{}; |
| 76 | KLightConditionVariable cond_var; | 76 | KLightConditionVariable cond_var; |
| 77 | KernelCore& kernel; | 77 | KernelCore& kernel; |