2018-11-27 00:31:22 +01: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"
|
2020-04-29 06:53:53 +02:00
|
|
|
#include "common/logging/log.h"
|
2018-12-05 00:54:18 +01:00
|
|
|
#include "core/hle/kernel/errors.h"
|
2020-12-03 03:08:35 +01:00
|
|
|
#include "core/hle/kernel/k_scheduler.h"
|
2020-12-31 08:01:08 +01:00
|
|
|
#include "core/hle/kernel/k_thread.h"
|
2020-02-25 21:38:33 +01:00
|
|
|
#include "core/hle/kernel/kernel.h"
|
2018-11-27 00:31:22 +01:00
|
|
|
#include "core/hle/kernel/object.h"
|
|
|
|
#include "core/hle/kernel/readable_event.h"
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
2020-12-22 07:36:53 +01:00
|
|
|
ReadableEvent::ReadableEvent(KernelCore& kernel) : KSynchronizationObject{kernel} {}
|
2018-11-27 00:31:22 +01:00
|
|
|
ReadableEvent::~ReadableEvent() = default;
|
|
|
|
|
|
|
|
void ReadableEvent::Signal() {
|
2020-05-02 20:07:29 +02:00
|
|
|
if (is_signaled) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
is_signaled = true;
|
2020-12-22 07:36:53 +01:00
|
|
|
NotifyAvailable();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ReadableEvent::IsSignaled() const {
|
|
|
|
ASSERT(kernel.GlobalSchedulerContext().IsLocked());
|
|
|
|
|
|
|
|
return is_signaled;
|
2018-11-27 00:31:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReadableEvent::Clear() {
|
2020-02-11 22:36:39 +01:00
|
|
|
is_signaled = false;
|
2018-11-27 00:31:22 +01:00
|
|
|
}
|
|
|
|
|
2018-12-05 00:54:18 +01:00
|
|
|
ResultCode ReadableEvent::Reset() {
|
2020-12-04 07:26:42 +01:00
|
|
|
KScopedSchedulerLock lock(kernel);
|
2020-02-11 22:36:39 +01:00
|
|
|
if (!is_signaled) {
|
2020-06-04 14:27:15 +02:00
|
|
|
LOG_TRACE(Kernel, "Handle is not signaled! object_id={}, object_type={}, object_name={}",
|
2020-04-29 06:53:53 +02:00
|
|
|
GetObjectId(), GetTypeName(), GetName());
|
2018-12-05 00:54:18 +01:00
|
|
|
return ERR_INVALID_STATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Clear();
|
|
|
|
|
|
|
|
return RESULT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2018-11-27 00:31:22 +01:00
|
|
|
} // namespace Kernel
|