SkyWay for Linux
読み取り中…
検索中…
一致する文字列を見つけられません
worker.hpp
1//
2// worker.hpp
3// skyway
4//
5// Created by Naoto Takahashi on 2024/03/05.
6// Copyright © 2024 NTT Communications. All rights reserved.
7//
8
9#ifndef SKYWAY_GLOBAL_WORKER_HPP_
10#define SKYWAY_GLOBAL_WORKER_HPP_
11
12#include <deque>
13#include <mutex>
14#include <thread>
15#include <condition_variable>
16
17#include "skyway/global/interface/worker.hpp"
18
19namespace skyway {
20namespace global {
21
23class Worker : public interface::Worker {
24public:
25 using Task = std::function<void()>;
26
27 Worker();
32 ~Worker();
33
34 void AddTask(Task& task) override;
35 void AddTask(const Task&& task) override;
36 void Join() override;
37
38private:
39 void ProcessWorker();
40 std::deque<Task> tasks_;
41 std::mutex mtx_;
42 std::condition_variable cv_;
43 bool is_termination_requested_ = false;
44 std::thread worker_;
45};
47
48} // namespace global
49} // namespace skyway
50
51#endif /* SKYWAY_GLOBAL_WORKER_HPP_ */