diff options
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/kernel/writable_event.cpp | 57 |
1 files changed, 12 insertions, 45 deletions
diff --git a/src/core/hle/kernel/writable_event.cpp b/src/core/hle/kernel/writable_event.cpp index 4eb387ac0..27d7ff734 100644 --- a/src/core/hle/kernel/writable_event.cpp +++ b/src/core/hle/kernel/writable_event.cpp @@ -12,70 +12,37 @@ namespace Kernel { -WritableEvent::WritableEvent(KernelCore& kernel) : WaitObject{kernel} {} +WritableEvent::WritableEvent(KernelCore& kernel) : Object{kernel} {} WritableEvent::~WritableEvent() = default; -std::tuple<SharedPtr<WritableEvent>, SharedPtr<ReadableEvent>> WritableEvent::CreateEventPair( - KernelCore& kernel, ResetType reset_type, std::string name) { +EventPair WritableEvent::CreateEventPair(KernelCore& kernel, ResetType reset_type, + std::string name) { SharedPtr<WritableEvent> writable_event(new WritableEvent(kernel)); SharedPtr<ReadableEvent> readable_event(new ReadableEvent(kernel)); writable_event->name = name + ":Writable"; - writable_event->signaled = false; - writable_event->reset_type = reset_type; + writable_event->readable = readable_event; readable_event->name = name + ":Readable"; - readable_event->writable_event = writable_event; + readable_event->signaled = false; + readable_event->reset_type = reset_type; - return std::make_tuple(std::move(writable_event), std::move(readable_event)); + return {std::move(readable_event), std::move(writable_event)}; } -SharedPtr<WritableEvent> WritableEvent::CreateRegisteredEventPair(KernelCore& kernel, - ResetType reset_type, - std::string name) { - auto [writable_event, readable_event] = CreateEventPair(kernel, reset_type, name); - kernel.AddNamedEvent(name, std::move(readable_event)); - return std::move(writable_event); -} - -bool WritableEvent::ShouldWait(Thread* thread) const { - return !signaled; -} - -void WritableEvent::Acquire(Thread* thread) { - ASSERT_MSG(!ShouldWait(thread), "object unavailable!"); - - if (reset_type == ResetType::OneShot) - signaled = false; +ResetType WritableEvent::GetResetType() const { + return readable->reset_type; } void WritableEvent::Signal() { - signaled = true; - WakeupAllWaitingThreads(); + readable->Signal(); } void WritableEvent::Clear() { - signaled = false; -} - -void WritableEvent::ResetOnAcquire() { - if (reset_type == ResetType::OneShot) - Clear(); -} - -void WritableEvent::ResetOnWakeup() { - if (reset_type == ResetType::Pulse) - Clear(); + readable->Clear(); } bool WritableEvent::IsSignaled() const { - return signaled; -} - -void WritableEvent::WakeupAllWaitingThreads() { - WaitObject::WakeupAllWaitingThreads(); - - if (reset_type == ResetType::Pulse) - signaled = false; + return readable->signaled; } } // namespace Kernel |