mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-16 16:50:04 +00:00
b1d5db1cf6
# Conflicts: # src/core/CMakeLists.txt # src/core/arm/dynarmic/arm_dynarmic.cpp # src/core/arm/dyncom/arm_dyncom.cpp # src/core/hle/kernel/process.cpp # src/core/hle/kernel/thread.cpp # src/core/hle/kernel/thread.h # src/core/hle/kernel/vm_manager.cpp # src/core/loader/3dsx.cpp # src/core/loader/elf.cpp # src/core/loader/ncch.cpp # src/core/memory.cpp # src/core/memory.h # src/core/memory_setup.h
61 lines
1.8 KiB
C++
61 lines
1.8 KiB
C++
// Copyright 2014 Citra Emulator Project
|
|
// Licensed under GPLv2 or any later version
|
|
// Refer to the license.txt file included.
|
|
|
|
#pragma once
|
|
|
|
#include <queue>
|
|
#include <string>
|
|
#include "common/common_types.h"
|
|
#include "core/hle/kernel/kernel.h"
|
|
#include "core/hle/kernel/wait_object.h"
|
|
#include "core/hle/result.h"
|
|
|
|
namespace Kernel {
|
|
|
|
class Semaphore final : public WaitObject {
|
|
public:
|
|
/**
|
|
* Creates a semaphore.
|
|
* @param initial_count Number of slots reserved for other threads
|
|
* @param max_count Maximum number of slots the semaphore can have
|
|
* @param name Optional name of semaphore
|
|
* @return The created semaphore
|
|
*/
|
|
static ResultVal<SharedPtr<Semaphore>> Create(s32 initial_count, s32 max_count, VAddr address,
|
|
std::string name = "Unknown");
|
|
|
|
std::string GetTypeName() const override {
|
|
return "Semaphore";
|
|
}
|
|
std::string GetName() const override {
|
|
return name;
|
|
}
|
|
|
|
static const 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
|
|
VAddr address;
|
|
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);
|
|
|
|
private:
|
|
Semaphore();
|
|
~Semaphore() override;
|
|
};
|
|
|
|
} // namespace
|