IPreciseSleepEvent.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. namespace Ryujinx.Common.PreciseSleep
  3. {
  4. /// <summary>
  5. /// An event which works similarly to an AutoResetEvent, but is backed by a
  6. /// more precise timer that allows waits of less than a millisecond.
  7. /// </summary>
  8. public interface IPreciseSleepEvent : IDisposable
  9. {
  10. /// <summary>
  11. /// Adjust a timepoint to better fit the host clock.
  12. /// When no adjustment is made, the input timepoint will be returned.
  13. /// </summary>
  14. /// <param name="timePoint">Timepoint to adjust</param>
  15. /// <param name="timeoutNs">Requested timeout in nanoseconds</param>
  16. /// <returns>Adjusted timepoint</returns>
  17. long AdjustTimePoint(long timePoint, long timeoutNs);
  18. /// <summary>
  19. /// Sleep until a timepoint, or a signal is received.
  20. /// Given no signal, may wake considerably before, or slightly after the timeout.
  21. /// </summary>
  22. /// <param name="timePoint">Timepoint to sleep until</param>
  23. /// <returns>True if signalled or waited, false if a wait could not be performed</returns>
  24. bool SleepUntil(long timePoint);
  25. /// <summary>
  26. /// Sleep until a signal is received.
  27. /// </summary>
  28. void Sleep();
  29. /// <summary>
  30. /// Signal the event, waking any sleeping thread or the next attempted sleep.
  31. /// </summary>
  32. void Signal();
  33. }
  34. }