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

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

unix.superglobalmegacorp.com

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