|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2021 nono project
4: // Licensed under nono-license.txt
5: //
6:
7: //
8: // スレッドを持つデバイス
9: //
10:
11: #pragma once
12:
13: #include "device.h"
14: #include <mutex>
15: #include <thread>
16:
17: class ThreadDevice : public Device
18: {
19: using inherited = Device;
20: public:
1.1.1.2 ! root 21: ThreadDevice(int objid_);
1.1 root 22: virtual ~ThreadDevice() override;
23:
24: // スレッド名を設定する
25: void SetThreadName(const char *threadname_);
26:
27: // スレッドを開始する
28: virtual bool StartThread();
29:
30: // スレッドに終了を要求し、その終了を待つ
31: void TerminateThread();
32:
33: protected:
34: // スレッドエントリポイント
35: virtual void ThreadRun() = 0;
36:
37: // スレッドに終了を指示する
38: virtual void Terminate() = 0;
39:
40: std::unique_ptr<std::thread> thread {};
41:
42: // スレッド開始同期用
43: std::mutex thread_starter {};
44:
45: // スレッド名
46: const char *threadname {};
47: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.