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