wait_proxy.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #pragma once
  2. #include <yt/cpp/mapreduce/interface/wait_proxy.h>
  3. namespace NYT {
  4. namespace NDetail {
  5. ////////////////////////////////////////////////////////////////////////////////
  6. class TDefaultWaitProxy
  7. : public IWaitProxy
  8. {
  9. public:
  10. bool WaitFuture(const ::NThreading::TFuture<void>& future, TDuration timeout) override;
  11. bool WaitEvent(TSystemEvent& event, TDuration timeout) override;
  12. bool WaitCondVar(TCondVar& condVar, TMutex& mutex, TDuration timeout) override;
  13. void Sleep(TDuration timeout) override;
  14. };
  15. class TWaitProxy {
  16. public:
  17. TWaitProxy();
  18. static TWaitProxy* Get();
  19. // NB: Non thread-safe, should be called only in initialization code.
  20. void SetProxy(::TIntrusivePtr<IWaitProxy> proxy);
  21. bool WaitFuture(const ::NThreading::TFuture<void>& future);
  22. bool WaitFuture(const ::NThreading::TFuture<void>& future, TInstant deadLine);
  23. bool WaitFuture(const ::NThreading::TFuture<void>& future, TDuration timeout);
  24. bool WaitEventD(TSystemEvent& event, TInstant deadLine);
  25. bool WaitEventT(TSystemEvent& event, TDuration timeout);
  26. void WaitEventI(TSystemEvent& event);
  27. bool WaitEvent(TSystemEvent& event);
  28. bool WaitCondVarD(TCondVar& condVar, TMutex& m, TInstant deadLine);
  29. bool WaitCondVarT(TCondVar& condVar, TMutex& m, TDuration timeOut);
  30. void WaitCondVarI(TCondVar& condVar, TMutex& m);
  31. void WaitCondVar(TCondVar& condVar, TMutex& m);
  32. void Sleep(TDuration timeout);
  33. void SleepUntil(TInstant instant);
  34. private:
  35. ::TIntrusivePtr<IWaitProxy> Proxy_;
  36. };
  37. ////////////////////////////////////////////////////////////////////////////////
  38. } // namespace NDetail
  39. } // namespace NYT