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