SkyWay Linux SDK
読み取り中…
検索中…
一致する文字列を見つけられません
worker.hpp
1//
2// © NTT DOCOMO BUSINESS, Inc. All Rights Reserved.
3//
4
5#ifndef SKYWAY_GLOBAL_WORKER_HPP_
6#define SKYWAY_GLOBAL_WORKER_HPP_
7
8#include <deque>
9#include <mutex>
10#include <thread>
11#include <condition_variable>
12
13#include "skyway/global/interface/worker.hpp"
14
15namespace skyway {
16namespace global {
17
19class Worker : public interface::Worker {
20public:
21 using Task = std::function<void()>;
22
32 Worker(const std::string& name);
37 ~Worker();
38
39 void AddTask(Task& task) override;
40 void AddTask(const Task&& task) override;
41 void Join() override;
42
43private:
44 void ProcessWorker(const std::string& name);
45 int SetThreadName(const std::string& name);
46 std::deque<Task> tasks_;
47 std::mutex mtx_;
48 std::condition_variable cv_;
49 bool is_termination_requested_ = false;
50 std::thread worker_;
51};
53
54} // namespace global
55} // namespace skyway
56
57#endif /* SKYWAY_GLOBAL_WORKER_HPP_ */