wait_for.h 798 B

1234567891011121314
  1. #pragma once
  2. #include <util/datetime/base.h>
  3. #include <util/system/yassert.h>
  4. #define UNIT_WAIT_FOR(condition) \
  5. do { \
  6. TInstant start(TInstant::Now()); \
  7. while (!(condition) && (TInstant::Now() - start < TDuration::Seconds(10))) { \
  8. Sleep(TDuration::MilliSeconds(1)); \
  9. } \
  10. /* TODO: use UNIT_ASSERT if in unittest thread */ \
  11. Y_ABORT_UNLESS(condition, "condition failed after 10 seconds wait"); \
  12. } while (0)