mutex.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. union ResultCode;
  7. namespace Core {
  8. class System;
  9. }
  10. namespace Kernel {
  11. class Mutex final {
  12. public:
  13. explicit Mutex(Core::System& system);
  14. ~Mutex();
  15. /// Flag that indicates that a mutex still has threads waiting for it.
  16. static constexpr u32 MutexHasWaitersFlag = 0x40000000;
  17. /// Mask of the bits in a mutex address value that contain the mutex owner.
  18. static constexpr u32 MutexOwnerMask = 0xBFFFFFFF;
  19. /// Attempts to acquire a mutex at the specified address.
  20. ResultCode TryAcquire(VAddr address, Handle holding_thread_handle,
  21. Handle requesting_thread_handle);
  22. /// Unlocks a mutex for owner at address
  23. std::pair<ResultCode, std::shared_ptr<Thread>> Unlock(std::shared_ptr<Thread> owner,
  24. VAddr address);
  25. /// Releases the mutex at the specified address.
  26. ResultCode Release(VAddr address);
  27. private:
  28. Core::System& system;
  29. };
  30. } // namespace Kernel