diff options
| author | 2024-02-06 23:09:43 -0500 | |
|---|---|---|
| committer | 2024-02-07 12:14:46 -0500 | |
| commit | 9404633bfd1e4ea23ccf8ef526b2b4c564ba512d (patch) | |
| tree | fe37bb0acf2383ecc625f3c278000ba5869ccbaa /src/core/hle/service/mutex.cpp | |
| parent | Merge pull request #12883 from FernandoS27/memory_manager_mem (diff) | |
| download | yuzu-9404633bfd1e4ea23ccf8ef526b2b4c564ba512d.tar.gz yuzu-9404633bfd1e4ea23ccf8ef526b2b4c564ba512d.tar.xz yuzu-9404633bfd1e4ea23ccf8ef526b2b4c564ba512d.zip | |
service: add os types and multi wait API
Diffstat (limited to 'src/core/hle/service/mutex.cpp')
| -rw-r--r-- | src/core/hle/service/mutex.cpp | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/src/core/hle/service/mutex.cpp b/src/core/hle/service/mutex.cpp deleted file mode 100644 index b0ff71d1b..000000000 --- a/src/core/hle/service/mutex.cpp +++ /dev/null | |||
| @@ -1,46 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "core/core.h" | ||
| 5 | #include "core/hle/kernel/k_event.h" | ||
| 6 | #include "core/hle/kernel/k_synchronization_object.h" | ||
| 7 | #include "core/hle/service/mutex.h" | ||
| 8 | |||
| 9 | namespace Service { | ||
| 10 | |||
| 11 | Mutex::Mutex(Core::System& system) : m_system(system) { | ||
| 12 | m_event = Kernel::KEvent::Create(system.Kernel()); | ||
| 13 | m_event->Initialize(nullptr); | ||
| 14 | |||
| 15 | // Register the event. | ||
| 16 | Kernel::KEvent::Register(system.Kernel(), m_event); | ||
| 17 | |||
| 18 | ASSERT(R_SUCCEEDED(m_event->Signal())); | ||
| 19 | } | ||
| 20 | |||
| 21 | Mutex::~Mutex() { | ||
| 22 | m_event->GetReadableEvent().Close(); | ||
| 23 | m_event->Close(); | ||
| 24 | } | ||
| 25 | |||
| 26 | void Mutex::lock() { | ||
| 27 | // Infinitely retry until we successfully clear the event. | ||
| 28 | while (R_FAILED(m_event->GetReadableEvent().Reset())) { | ||
| 29 | s32 index; | ||
| 30 | Kernel::KSynchronizationObject* obj = &m_event->GetReadableEvent(); | ||
| 31 | |||
| 32 | // The event was already cleared! | ||
| 33 | // Wait for it to become signaled again. | ||
| 34 | ASSERT(R_SUCCEEDED( | ||
| 35 | Kernel::KSynchronizationObject::Wait(m_system.Kernel(), &index, &obj, 1, -1))); | ||
| 36 | } | ||
| 37 | |||
| 38 | // We successfully cleared the event, and now have exclusive ownership. | ||
| 39 | } | ||
| 40 | |||
| 41 | void Mutex::unlock() { | ||
| 42 | // Unlock. | ||
| 43 | ASSERT(R_SUCCEEDED(m_event->Signal())); | ||
| 44 | } | ||
| 45 | |||
| 46 | } // namespace Service | ||