mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-13 00:26:35 +00:00
strat: avoid using unique_lock in a few places
This commit is contained in:
parent
6a2ee02409
commit
b4122da6ad
2 changed files with 9 additions and 9 deletions
|
@ -22,10 +22,10 @@ namespace ams::fssystem {
|
||||||
NON_COPYABLE(KeySlotCacheAccessor);
|
NON_COPYABLE(KeySlotCacheAccessor);
|
||||||
NON_MOVEABLE(KeySlotCacheAccessor);
|
NON_MOVEABLE(KeySlotCacheAccessor);
|
||||||
private:
|
private:
|
||||||
std::unique_lock<os::Mutex> lk;
|
std::scoped_lock<os::Mutex> lk;
|
||||||
const s32 slot_index;
|
const s32 slot_index;
|
||||||
public:
|
public:
|
||||||
KeySlotCacheAccessor(s32 idx, std::unique_lock<os::Mutex> &&l) : lk(std::move(l)), slot_index(idx) { /* ... */ }
|
KeySlotCacheAccessor(s32 idx, std::scoped_lock<os::Mutex> &&l) : lk(std::move(l)), slot_index(idx) { /* ... */ }
|
||||||
|
|
||||||
s32 GetKeySlotIndex() const { return this->slot_index; }
|
s32 GetKeySlotIndex() const { return this->slot_index; }
|
||||||
};
|
};
|
||||||
|
@ -79,7 +79,7 @@ namespace ams::fssystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
Result Find(std::unique_ptr<KeySlotCacheAccessor> *out, const void *key, size_t key_size, s32 key2) {
|
Result Find(std::unique_ptr<KeySlotCacheAccessor> *out, const void *key, size_t key_size, s32 key2) {
|
||||||
std::unique_lock lk(this->mutex);
|
std::scoped_lock lk(this->mutex);
|
||||||
|
|
||||||
KeySlotCacheEntryList *lists[2] = { std::addressof(this->high_priority_mru_list), std::addressof(this->low_priority_mru_list) };
|
KeySlotCacheEntryList *lists[2] = { std::addressof(this->high_priority_mru_list), std::addressof(this->low_priority_mru_list) };
|
||||||
for (auto list : lists) {
|
for (auto list : lists) {
|
||||||
|
@ -100,12 +100,12 @@ namespace ams::fssystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddEntry(KeySlotCacheEntry *entry) {
|
void AddEntry(KeySlotCacheEntry *entry) {
|
||||||
std::unique_lock lk(this->mutex);
|
std::scoped_lock lk(this->mutex);
|
||||||
this->low_priority_mru_list.push_front(*entry);
|
this->low_priority_mru_list.push_front(*entry);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
Result AllocateFromLru(std::unique_ptr<KeySlotCacheAccessor> *out, KeySlotCacheEntryList &dst_list, const void *key, size_t key_size, s32 key2) {
|
Result AllocateFromLru(std::unique_ptr<KeySlotCacheAccessor> *out, KeySlotCacheEntryList &dst_list, const void *key, size_t key_size, s32 key2) {
|
||||||
std::unique_lock lk(this->mutex);
|
std::scoped_lock lk(this->mutex);
|
||||||
|
|
||||||
KeySlotCacheEntryList &src_list = this->low_priority_mru_list.empty() ? this->high_priority_mru_list : this->low_priority_mru_list;
|
KeySlotCacheEntryList &src_list = this->low_priority_mru_list.empty() ? this->high_priority_mru_list : this->low_priority_mru_list;
|
||||||
AMS_ASSERT(!src_list.empty());
|
AMS_ASSERT(!src_list.empty());
|
||||||
|
|
|
@ -55,14 +55,14 @@ namespace ams::os::impl {
|
||||||
manager.NotifyThreadNameChanged(thread);
|
manager.NotifyThreadNameChanged(thread);
|
||||||
|
|
||||||
{
|
{
|
||||||
std::unique_lock lk(GetReference(thread->cs_thread));
|
GetReference(thread->cs_thread).Lock();
|
||||||
while (thread->state == ThreadType::State_Initialized) {
|
while (thread->state == ThreadType::State_Initialized) {
|
||||||
GetReference(thread->cv_thread).Wait(GetPointer(thread->cs_thread));
|
GetReference(thread->cv_thread).Wait(GetPointer(thread->cs_thread));
|
||||||
}
|
}
|
||||||
|
const auto new_state = thread->state;
|
||||||
|
GetReference(thread->cs_thread).Unlock();
|
||||||
|
|
||||||
if (thread->state == ThreadType::State_Started) {
|
if (new_state == ThreadType::State_Started) {
|
||||||
lk.unlock();
|
|
||||||
|
|
||||||
thread->function(thread->argument);
|
thread->function(thread->argument);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue