mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2026-04-29 07:14:41 -06:00
Some objects declare their handle type as const, while others declare it as constexpr. This makes the const ones constexpr for consistency, and prevent unexpected compilation errors if these happen to be attempted to be used within a constexpr context.
49 lines
1.3 KiB
C++
49 lines
1.3 KiB
C++
// Copyright 2014 Citra Emulator Project
|
|
// Licensed under GPLv2 or any later version
|
|
// Refer to the license.txt file included.
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <queue>
|
|
#include "common/common_types.h"
|
|
#include "core/hle/kernel/object.h"
|
|
#include "core/hle/kernel/wait_object.h"
|
|
#include "core/hle/result.h"
|
|
|
|
namespace Kernel {
|
|
|
|
class Semaphore final : public WaitObject {
|
|
public:
|
|
explicit Semaphore(KernelSystem& kernel);
|
|
~Semaphore() override;
|
|
|
|
std::string GetTypeName() const override {
|
|
return "Semaphore";
|
|
}
|
|
std::string GetName() const override {
|
|
return name;
|
|
}
|
|
|
|
static constexpr HandleType HANDLE_TYPE = HandleType::Semaphore;
|
|
HandleType GetHandleType() const override {
|
|
return HANDLE_TYPE;
|
|
}
|
|
|
|
s32 max_count; ///< Maximum number of simultaneous holders the semaphore can have
|
|
s32 available_count; ///< Number of free slots left in the semaphore
|
|
std::string name; ///< Name of semaphore (optional)
|
|
|
|
bool ShouldWait(Thread* thread) const override;
|
|
void Acquire(Thread* thread) override;
|
|
|
|
/**
|
|
* Releases a certain number of slots from a semaphore.
|
|
* @param release_count The number of slots to release
|
|
* @return The number of free slots the semaphore had before this call
|
|
*/
|
|
ResultVal<s32> Release(s32 release_count);
|
|
};
|
|
|
|
} // namespace Kernel
|