2020-02-11 21:36:39 +00:00
|
|
|
// Copyright 2020 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <utility>
|
2020-02-13 21:01:44 +00:00
|
|
|
#include <vector>
|
2020-02-11 21:36:39 +00:00
|
|
|
|
|
|
|
#include "core/hle/kernel/object.h"
|
|
|
|
#include "core/hle/result.h"
|
|
|
|
|
|
|
|
namespace Core {
|
|
|
|
class System;
|
|
|
|
} // namespace Core
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
class SynchronizationObject;
|
|
|
|
|
2020-02-13 21:01:44 +00:00
|
|
|
/**
|
|
|
|
* The 'Synchronization' class is an interface for handling synchronization methods
|
|
|
|
* used by Synchronization objects and synchronization SVCs. This centralizes processing of
|
|
|
|
* such
|
|
|
|
*/
|
2020-02-11 21:36:39 +00:00
|
|
|
class Synchronization {
|
|
|
|
public:
|
2020-02-13 21:01:44 +00:00
|
|
|
explicit Synchronization(Core::System& system);
|
2020-02-11 21:36:39 +00:00
|
|
|
|
2020-02-13 21:01:44 +00:00
|
|
|
/// Signals a synchronization object, waking up all its waiting threads
|
2020-02-11 21:36:39 +00:00
|
|
|
void SignalObject(SynchronizationObject& obj) const;
|
|
|
|
|
2020-02-13 21:01:44 +00:00
|
|
|
/// Tries to see if waiting for any of the sync_objects is necessary, if not
|
|
|
|
/// it returns Success and the handle index of the signaled sync object. In
|
|
|
|
/// case not, the current thread will be locked and wait for nano_seconds or
|
|
|
|
/// for a synchronization object to signal.
|
2020-02-11 21:36:39 +00:00
|
|
|
std::pair<ResultCode, Handle> WaitFor(
|
|
|
|
std::vector<std::shared_ptr<SynchronizationObject>>& sync_objects, s64 nano_seconds);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Core::System& system;
|
|
|
|
};
|
|
|
|
} // namespace Kernel
|