2020-02-19 21:44:56 +00:00
|
|
|
#ifndef WF_TEST_TIMEOUT_WATCHER_HPP
|
|
|
|
#define WF_TEST_TIMEOUT_WATCHER_HPP
|
|
|
|
|
|
|
|
#include <chrono>
|
2020-06-13 21:47:52 +00:00
|
|
|
#include <functional>
|
2020-02-19 21:44:56 +00:00
|
|
|
|
|
|
|
namespace webfuse_test
|
|
|
|
{
|
|
|
|
|
|
|
|
class TimeoutWatcher final
|
|
|
|
{
|
|
|
|
TimeoutWatcher(TimeoutWatcher const & other) = delete;
|
|
|
|
TimeoutWatcher& operator=(TimeoutWatcher const & other) = delete;
|
|
|
|
public:
|
|
|
|
explicit TimeoutWatcher(std::chrono::milliseconds timeout);
|
|
|
|
~TimeoutWatcher();
|
|
|
|
bool isTimeout();
|
|
|
|
void check();
|
2020-06-13 21:47:52 +00:00
|
|
|
bool waitUntil(std::function<bool()> predicate);
|
2020-02-19 21:44:56 +00:00
|
|
|
private:
|
|
|
|
std::chrono::milliseconds startedAt;
|
|
|
|
std::chrono::milliseconds timeout_;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|