/** * * @file TaskTimeoutFlag.h * @author An Tao * * Copyright 2018, An Tao. All rights reserved. * https://github.com/an-tao/drogon * Use of this source code is governed by a MIT license * that can be found in the License file. * * Drogon * */ #pragma once #include #include #include #include #include #include namespace drogon { class TaskTimeoutFlag : public trantor::NonCopyable, public std::enable_shared_from_this { public: TaskTimeoutFlag(trantor::EventLoop *loop, const std::chrono::duration &timeout, std::function timeoutCallback); bool done(); void runTimer(); private: std::atomic isDone_{false}; trantor::EventLoop *loop_; std::chrono::duration timeout_; std::function timeoutFunc_; }; } // namespace drogon