mutex.h 1001 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include "common/common_types.h"
  6. #include "core/hle/kernel/object.h"
  7. union ResultCode;
  8. namespace Kernel {
  9. class HandleTable;
  10. class Thread;
  11. class Mutex final {
  12. public:
  13. /// Flag that indicates that a mutex still has threads waiting for it.
  14. static constexpr u32 MutexHasWaitersFlag = 0x40000000;
  15. /// Mask of the bits in a mutex address value that contain the mutex owner.
  16. static constexpr u32 MutexOwnerMask = 0xBFFFFFFF;
  17. /// Attempts to acquire a mutex at the specified address.
  18. static ResultCode TryAcquire(HandleTable& handle_table, VAddr address,
  19. Handle holding_thread_handle, Handle requesting_thread_handle);
  20. /// Releases the mutex at the specified address.
  21. static ResultCode Release(VAddr address);
  22. private:
  23. Mutex() = default;
  24. ~Mutex() = default;
  25. };
  26. } // namespace Kernel