1
0
Fork 0
forked from suyu/suyu

kernel: ResourceLimit::Reserve remove useless while loop

Timeout is a u64, it will always be >= 0
This commit is contained in:
David Marcec 2020-05-29 13:48:01 +10:00
parent 5242b21524
commit 43bf860b22

View file

@ -24,13 +24,9 @@ bool ResourceLimit::Reserve(ResourceType resource, s64 amount, u64 timeout) {
const std::size_t index{ResourceTypeToIndex(resource)}; const std::size_t index{ResourceTypeToIndex(resource)};
s64 new_value = current[index] + amount; s64 new_value = current[index] + amount;
while (new_value > limit[index] && available[index] + amount <= limit[index]) { if (new_value > limit[index] && available[index] + amount <= limit[index]) {
// TODO(bunnei): This is wrong for multicore, we should wait the calling thread for timeout // TODO(bunnei): This is wrong for multicore, we should wait the calling thread for timeout
new_value = current[index] + amount; new_value = current[index] + amount;
if (timeout >= 0) {
break;
}
} }
if (new_value <= limit[index]) { if (new_value <= limit[index]) {