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 86 : static AicpusdLastword &GetInstance()
23 : {
24 91 : static AicpusdLastword instance;
25 86 : return instance;
26 : }
27 : void RegLastwordCallback(const std::string mark, std::function<void ()> callback,
28 : std::function<void ()> &cancelReg);
29 : void LastwordCallback();
30 :
31 : private:
32 : std::mutex lastwordMux_;
33 : uint64_t lastwordKey_ = 0;
34 : std::map<uint64_t, std::pair<std::string, std::function<void()>>> lastwords_;
35 : };
36 : }
37 : #endif // CORE_AICPUSD_LASTWORD_H
|