mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-26 13:52:21 +00:00
kern: use std::atomic_ref instead of reinterpret_cast to std::atomic
This commit is contained in:
parent
48e8562033
commit
3c85e37667
1 changed files with 5 additions and 3 deletions
|
@ -276,10 +276,12 @@ namespace ams::kern {
|
|||
void KScheduler::ClearPreviousThread(KThread *thread) {
|
||||
MESOSPHERE_ASSERT(IsSchedulerLockedByCurrentThread());
|
||||
for (size_t i = 0; i < cpu::NumCores; ++i) {
|
||||
std::atomic<KThread *> *prev_thread_ptr = reinterpret_cast<std::atomic<KThread *> *>(std::addressof(Kernel::GetScheduler(static_cast<s32>(i)).prev_thread));
|
||||
static_assert(sizeof(*prev_thread_ptr) == sizeof(KThread *));
|
||||
/* Get an atomic reference to the core scheduler's previous thread. */
|
||||
std::atomic_ref<KThread *> prev_thread(Kernel::GetScheduler(static_cast<s32>(i)).prev_thread);
|
||||
static_assert(std::atomic_ref<KThread *>::is_always_lock_free);
|
||||
|
||||
prev_thread_ptr->compare_exchange_weak(thread, nullptr);
|
||||
/* Atomically clear the previous thread if it's our target. */
|
||||
prev_thread.compare_exchange_weak(thread, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue