blob: 3d4ce1fbc8d6b1a2419d1e77af561a72c7a6a45c (
plain) (
tree)
|
|
// Copyright 2021 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <vector>
#include "core/hle/kernel/k_auto_object.h"
#include "core/hle/result.h"
namespace Kernel {
class KernelCore;
class Synchronization;
class KThread;
/// Class that represents a Kernel object that a thread can be waiting on
class KSynchronizationObject : public KAutoObjectWithList {
KERNEL_AUTOOBJECT_TRAITS(KSynchronizationObject, KAutoObject);
public:
struct ThreadListNode {
ThreadListNode* next{};
KThread* thread{};
};
[[nodiscard]] static ResultCode Wait(KernelCore& kernel, s32* out_index,
KSynchronizationObject** objects, const s32 num_objects,
s64 timeout);
void Finalize() override;
[[nodiscard]] virtual bool IsSignaled() const = 0;
[[nodiscard]] std::vector<KThread*> GetWaitingThreadsForDebugging() const;
protected:
explicit KSynchronizationObject(KernelCore& kernel);
~KSynchronizationObject() override;
virtual void OnFinalizeSynchronizationObject() {}
void NotifyAvailable(ResultCode result);
void NotifyAvailable() {
return this->NotifyAvailable(RESULT_SUCCESS);
}
private:
ThreadListNode* thread_list_head{};
ThreadListNode* thread_list_tail{};
};
} // namespace Kernel
|