Annotation of nono/vm/uimessage.cpp, revision 1.1.1.3

1.1       root        1: //
                      2: // nono
                      3: // Copyright (C) 2021 nono project
                      4: // Licensed under nono-license.txt
                      5: //
                      6: 
1.1.1.2   root        7: //
                      8: // UI スレッドへのメッセージ機構
                      9: //
                     10: 
1.1       root       11: #include "uimessage.h"
                     12: 
                     13: // コンストラクタ
                     14: UIMessage::UIMessage()
                     15: {
                     16: }
                     17: 
1.1.1.3 ! root       18: // デストラクタ
        !            19: UIMessage::~UIMessage()
1.1       root       20: {
                     21: }
                     22: 
1.1.1.3 ! root       23: // コールバック関数をセットして、サービスを開始。
1.1       root       24: void
1.1.1.3 ! root       25: UIMessage::StartUIMessage(const std::function<void(uint, int)>& func_)
1.1       root       26: {
1.1.1.3 ! root       27:        std::lock_guard<std::mutex> lock(mtx);
        !            28:        func = func_;
1.1       root       29: }
                     30: 
1.1.1.3 ! root       31: // サービスを停止。
        !            32: void
        !            33: UIMessage::StopUIMessage()
1.1       root       34: {
1.1.1.3 ! root       35:        std::lock_guard<std::mutex> lock(mtx);
        !            36:        func = std::function<void(uint, int)>();
1.1       root       37: }
                     38: 
1.1.1.3 ! root       39: // UIMessage をポスト(実行)する。
        !            40: void
        !            41: UIMessage::Post(uint id, int arg)
1.1       root       42: {
1.1.1.3 ! root       43:        std::lock_guard<std::mutex> lock(mtx);
        !            44:        if ((bool)func) {
        !            45:                func(id, arg);
        !            46:        }
1.1       root       47: }

unix.superglobalmegacorp.com

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