2018-11-26 15:31:22 -08:00
|
|
|
// Copyright 2014 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include "common/assert.h"
|
|
|
|
#include "core/hle/kernel/object.h"
|
|
|
|
#include "core/hle/kernel/readable_event.h"
|
|
|
|
#include "core/hle/kernel/thread.h"
|
|
|
|
#include "core/hle/kernel/writable_event.h"
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
ReadableEvent::ReadableEvent(KernelCore& kernel) : WaitObject{kernel} {}
|
|
|
|
ReadableEvent::~ReadableEvent() = default;
|
|
|
|
|
|
|
|
bool ReadableEvent::ShouldWait(Thread* thread) const {
|
2018-11-27 06:18:29 -08:00
|
|
|
return !signaled;
|
2018-11-26 15:31:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReadableEvent::Acquire(Thread* thread) {
|
|
|
|
ASSERT_MSG(!ShouldWait(thread), "object unavailable!");
|
|
|
|
|
2018-11-27 06:18:29 -08:00
|
|
|
if (reset_type == ResetType::OneShot)
|
|
|
|
signaled = false;
|
2018-11-26 15:31:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReadableEvent::Signal() {
|
2018-11-27 06:18:29 -08:00
|
|
|
signaled = true;
|
|
|
|
WakeupAllWaitingThreads();
|
2018-11-26 15:31:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReadableEvent::Clear() {
|
2018-11-27 06:18:29 -08:00
|
|
|
signaled = false;
|
2018-11-26 15:31:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReadableEvent::WakeupAllWaitingThreads() {
|
2018-11-27 06:18:29 -08:00
|
|
|
WaitObject::WakeupAllWaitingThreads();
|
|
|
|
|
|
|
|
if (reset_type == ResetType::Pulse)
|
|
|
|
signaled = false;
|
2018-11-26 15:31:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Kernel
|