mutex.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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, VAddr address);
  24. /// Releases the mutex at the specified address.
  25. ResultCode Release(VAddr address);
  26. private:
  27. Core::System& system;
  28. };
  29. } // namespace Kernel