/** .============.* // M A K E / \* // C++ DEV / \* // E A S Y / \/ \* ++ ----------. \/\ .* \\ \ \ /\ /* \\ \ \ /* \\ \ \ /* -============'** Copyright (c) 2018 Hevake and contributors, all rights reserved.** This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox)* Use of this source code is governed by MIT license that can be found* in the LICENSE file in the root of the source tree. All contributing* project authors may be found in the CONTRIBUTORS.md file in the root* of the source tree.*/#ifndef TBOX_EVENTX_LOOP_THREAD_H_20230604#define TBOX_EVENTX_LOOP_THREAD_H_20230604#include <string>#include <thread>#include <tbox/base/defines.h>#include <tbox/event/loop.h>namespace tbox {namespace eventx {/// 单独运行Loop的线程class LoopThread {public:/*** \param run_now 是否立即运行,否则需要在后面调用start()启动* \param loop_name Loop名称,用于LoopWDog监测报警时打印显示*/LoopThread(bool run_now = true,const std::string &loop_name = "loop_thread");~LoopThread();NONCOPYABLE(LoopThread);IMMOVABLE(LoopThread);public:/// 启动线程void start();/// 停止线程void stop();/// 线程是否正在运行bool isRunning() const { return is_running_; }/// 返回 Loop 对象/*** WARN:* 1.不能在外部直接 delete Loop 对象* 2.在运行过程中,仅能调用runInLoop()与run()*/event::Loop* loop() const { return loop_; };private:std::string name_;event::Loop *loop_;std::thread thread_;bool is_running_ = false;};}}#endif //TBOX_EVENTX_LOOP_THREAD_H_20230604
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型