Annotation of nono/vm/thread.h, revision 1.1.1.5

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: 
1.1.1.5 ! root       17: class ThreadBase
1.1       root       18: {
1.1.1.5 ! root       19:  protected:
1.1.1.4   root       20:        enum class AffinityClass {
                     21:                Light,  // 処理の軽いスレッド
                     22:                Heavy,  // 処理の重いスレッド
                     23:        };
                     24: 
1.1.1.5 ! root       25:        // このスレッドのアフィニティを示唆する
        !            26:        static void SetThreadAffinityHint(AffinityClass hint);
        !            27: };
        !            28: 
        !            29: class ThreadDevice : public Device, public ThreadBase
        !            30: {
        !            31:        using inherited = Device;
        !            32: 
1.1.1.4   root       33:  public:
                     34:        explicit ThreadDevice(uint objid_);
1.1.1.3   root       35:        ~ThreadDevice() override;
1.1       root       36: 
                     37:        // スレッドを開始する
                     38:        virtual bool StartThread();
                     39: 
                     40:        // スレッドに終了を要求し、その終了を待つ
                     41:        void TerminateThread();
                     42: 
                     43:  protected:
1.1.1.5 ! root       44:        // オブジェクト名とスレッド名を設定する。
        !            45:        void SetName(const std::string& newname) override;
        !            46: 
        !            47:        // スレッド名を設定する
        !            48:        void SetThreadName(const std::string& threadname_);
        !            49: 
1.1       root       50:        // スレッドエントリポイント
                     51:        virtual void ThreadRun() = 0;
                     52: 
                     53:        // スレッドに終了を指示する
                     54:        virtual void Terminate() = 0;
                     55: 
                     56:        std::unique_ptr<std::thread> thread {};
                     57: 
                     58:        // スレッド開始同期用
                     59:        std::mutex thread_starter {};
                     60: 
                     61:        // スレッド名
1.1.1.5 ! root       62:        std::string threadname {};
1.1       root       63: };

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.