2014-05-28 00:16:13 +00:00
|
|
|
// Copyright 2014 Citra Emulator Project
|
2014-12-17 05:38:14 +00:00
|
|
|
// Licensed under GPLv2 or any later version
|
2014-11-19 08:49:13 +00:00
|
|
|
// Refer to the license.txt file included.
|
2014-05-28 00:16:13 +00:00
|
|
|
|
2014-06-06 02:35:36 +00:00
|
|
|
#include <algorithm>
|
2016-09-18 00:38:01 +00:00
|
|
|
#include <map>
|
2014-05-28 00:16:13 +00:00
|
|
|
#include <vector>
|
2015-05-06 07:06:12 +00:00
|
|
|
#include "common/assert.h"
|
2016-09-21 06:52:38 +00:00
|
|
|
#include "core/hle/kernel/event.h"
|
2016-09-18 00:38:01 +00:00
|
|
|
#include "core/hle/kernel/kernel.h"
|
2014-06-06 02:35:36 +00:00
|
|
|
#include "core/hle/kernel/thread.h"
|
2014-05-28 00:16:13 +00:00
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
2016-09-19 01:01:46 +00:00
|
|
|
Event::Event() {}
|
|
|
|
Event::~Event() {}
|
2015-02-01 00:56:59 +00:00
|
|
|
|
2015-02-01 02:14:40 +00:00
|
|
|
SharedPtr<Event> Event::Create(ResetType reset_type, std::string name) {
|
2015-01-23 05:11:25 +00:00
|
|
|
SharedPtr<Event> evt(new Event);
|
2014-06-10 02:46:54 +00:00
|
|
|
|
2015-01-16 00:29:46 +00:00
|
|
|
evt->signaled = false;
|
2015-07-01 22:10:28 +00:00
|
|
|
evt->reset_type = reset_type;
|
2015-01-23 05:11:25 +00:00
|
|
|
evt->name = std::move(name);
|
2015-01-15 04:33:37 +00:00
|
|
|
|
2016-11-19 19:00:08 +00:00
|
|
|
if (reset_type == ResetType::Pulse) {
|
|
|
|
LOG_ERROR(Kernel, "Unimplemented event reset type Pulse");
|
|
|
|
UNIMPLEMENTED();
|
|
|
|
}
|
|
|
|
|
2015-02-01 02:14:40 +00:00
|
|
|
return evt;
|
2014-05-28 00:16:13 +00:00
|
|
|
}
|
|
|
|
|
2015-01-23 05:11:25 +00:00
|
|
|
bool Event::ShouldWait() {
|
|
|
|
return !signaled;
|
|
|
|
}
|
2014-05-28 00:16:13 +00:00
|
|
|
|
2015-01-23 05:11:25 +00:00
|
|
|
void Event::Acquire() {
|
2015-01-21 01:16:47 +00:00
|
|
|
ASSERT_MSG(!ShouldWait(), "object unavailable!");
|
2014-05-28 00:16:13 +00:00
|
|
|
|
2015-01-23 05:11:25 +00:00
|
|
|
// Release the event if it's not sticky...
|
2016-03-12 20:06:31 +00:00
|
|
|
if (reset_type != ResetType::Sticky)
|
2015-01-23 05:11:25 +00:00
|
|
|
signaled = false;
|
|
|
|
}
|
2014-05-28 00:16:13 +00:00
|
|
|
|
2015-01-23 05:11:25 +00:00
|
|
|
void Event::Signal() {
|
|
|
|
signaled = true;
|
|
|
|
WakeupAllWaitingThreads();
|
2014-05-28 00:16:13 +00:00
|
|
|
}
|
|
|
|
|
2015-01-23 05:11:25 +00:00
|
|
|
void Event::Clear() {
|
|
|
|
signaled = false;
|
2014-05-28 00:16:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|