2018-11-26 23:31:22 +00: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"
|
2018-12-04 23:54:18 +00:00
|
|
|
#include "core/hle/kernel/errors.h"
|
2018-11-26 23:31:22 +00:00
|
|
|
#include "core/hle/kernel/object.h"
|
|
|
|
#include "core/hle/kernel/readable_event.h"
|
|
|
|
#include "core/hle/kernel/thread.h"
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
2020-02-11 14:46:25 +00:00
|
|
|
ReadableEvent::ReadableEvent(KernelCore& kernel) : SynchronizationObject{kernel} {}
|
2018-11-26 23:31:22 +00:00
|
|
|
ReadableEvent::~ReadableEvent() = default;
|
|
|
|
|
2019-04-01 22:19:42 +00:00
|
|
|
bool ReadableEvent::ShouldWait(const Thread* thread) const {
|
2020-02-11 21:36:39 +00:00
|
|
|
return !is_signaled;
|
2018-11-26 23:31:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReadableEvent::Acquire(Thread* thread) {
|
2020-02-11 21:36:39 +00:00
|
|
|
ASSERT_MSG(IsSignaled(), "object unavailable!");
|
2018-11-26 23:31:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReadableEvent::Signal() {
|
2020-02-11 21:36:39 +00:00
|
|
|
if (!is_signaled) {
|
|
|
|
is_signaled = true;
|
|
|
|
SynchronizationObject::Signal();
|
2019-11-03 09:25:41 +00:00
|
|
|
};
|
2018-11-26 23:31:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReadableEvent::Clear() {
|
2020-02-11 21:36:39 +00:00
|
|
|
is_signaled = false;
|
2018-11-26 23:31:22 +00:00
|
|
|
}
|
|
|
|
|
2018-12-04 23:54:18 +00:00
|
|
|
ResultCode ReadableEvent::Reset() {
|
2020-02-11 21:36:39 +00:00
|
|
|
if (!is_signaled) {
|
2018-12-04 23:54:18 +00:00
|
|
|
return ERR_INVALID_STATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Clear();
|
|
|
|
|
|
|
|
return RESULT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2018-11-26 23:31:22 +00:00
|
|
|
} // namespace Kernel
|