suyu/src/core/hle/kernel/mutex.h

43 lines
1.1 KiB
C++
Raw Normal View History

2014-05-20 23:03:45 -04:00
// Copyright 2014 Citra Emulator Project
2014-12-17 00:38:14 -05:00
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
2014-05-20 23:03:45 -04:00
#pragma once
#include "common/common_types.h"
union ResultCode;
2014-05-20 23:03:45 -04:00
namespace Core {
class System;
}
2014-05-20 23:03:45 -04:00
namespace Kernel {
class Mutex final {
public:
explicit Mutex(Core::System& system);
~Mutex();
/// Flag that indicates that a mutex still has threads waiting for it.
static constexpr u32 MutexHasWaitersFlag = 0x40000000;
/// Mask of the bits in a mutex address value that contain the mutex owner.
static constexpr u32 MutexOwnerMask = 0xBFFFFFFF;
/// Attempts to acquire a mutex at the specified address.
ResultCode TryAcquire(VAddr address, Handle holding_thread_handle,
Handle requesting_thread_handle);
2020-02-25 16:37:12 -05:00
/// Unlocks a mutex for owner at address
2020-05-08 18:53:13 -04:00
std::pair<ResultCode, std::shared_ptr<Thread>> Unlock(std::shared_ptr<Thread> owner,
VAddr address);
2020-02-25 16:37:12 -05:00
/// Releases the mutex at the specified address.
ResultCode Release(VAddr address);
private:
Core::System& system;
};
2014-05-20 23:03:45 -04:00
2018-01-01 14:02:26 -05:00
} // namespace Kernel