synchronization.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2020 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <memory>
  6. #include <utility>
  7. #include <vector>
  8. #include "core/hle/kernel/object.h"
  9. #include "core/hle/result.h"
  10. namespace Core {
  11. class System;
  12. } // namespace Core
  13. namespace Kernel {
  14. class SynchronizationObject;
  15. /**
  16. * The 'Synchronization' class is an interface for handling synchronization methods
  17. * used by Synchronization objects and synchronization SVCs. This centralizes processing of
  18. * such
  19. */
  20. class Synchronization {
  21. public:
  22. explicit Synchronization(Core::System& system);
  23. /// Signals a synchronization object, waking up all its waiting threads
  24. void SignalObject(SynchronizationObject& obj) const;
  25. /// Tries to see if waiting for any of the sync_objects is necessary, if not
  26. /// it returns Success and the handle index of the signaled sync object. In
  27. /// case not, the current thread will be locked and wait for nano_seconds or
  28. /// for a synchronization object to signal.
  29. std::pair<ResultCode, Handle> WaitFor(
  30. std::vector<std::shared_ptr<SynchronizationObject>>& sync_objects, s64 nano_seconds);
  31. private:
  32. Core::System& system;
  33. };
  34. } // namespace Kernel