Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 : #ifndef CORE_AICPUSD_LASTWORD_H
11 : #define CORE_AICPUSD_LASTWORD_H
12 : #include <map>
13 : #include <atomic>
14 : #include <mutex>
15 : #include <functional>
16 : #include <string>
17 : #include <memory>
18 : #include <thread>
19 : namespace AicpuSchedule {
20 : class AicpusdLastword {
21 : public:
22 87 : static AicpusdLastword& GetInstance()
23 : {
24 92 : static AicpusdLastword instance;
25 87 : return instance;
26 : }
27 : void RegLastwordCallback(const std::string mark, std::function<void()> callback, std::function<void()>& cancelReg);
28 : void LastwordCallback();
29 :
30 : private:
31 : std::mutex lastwordMux_;
32 : uint64_t lastwordKey_ = 0;
33 : std::map<uint64_t, std::pair<std::string, std::function<void()>>> lastwords_;
34 : };
35 : } // namespace AicpuSchedule
36 : #endif // CORE_AICPUSD_LASTWORD_H
|