1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FFRT_SDEPENDENCE_MANAGER_H
17 #define FFRT_SDEPENDENCE_MANAGER_H
18 
19 #include "dependence_manager.h"
20 
21 namespace ffrt {
22 class SDependenceManager : public DependenceManager {
23 public:
Instance()24     static SDependenceManager& Instance()
25     {
26         static SDependenceManager ins;
27         return ins;
28     }
29 
30     void onSubmit(bool has_handle, ffrt_task_handle_t &handle, ffrt_function_header_t *f, const ffrt_deps_t *ins,
31         const ffrt_deps_t *outs, const task_attr_private *attr) override;
32 
33     void onWait() override;
34 
35 #ifdef QOS_DEPENDENCY
36     void onWait(const ffrt_deps_t* deps, int64_t deadline = -1) override;
37 #else
38     void onWait(const ffrt_deps_t* deps) override;
39 #endif
40 
41     int onExecResults(const ffrt_deps_t *deps) override;
42 
43     void onTaskDone(CPUEUTask* task) override;
44 
45 private:
46     SDependenceManager();
47     ~SDependenceManager() override;
48 
49     void RemoveRepeatedDeps(std::vector<CPUEUTask*>& in_handles, const ffrt_deps_t* ins, const ffrt_deps_t* outs,
50         std::vector<const void *>& insNoDup, std::vector<const void *>& outsNoDup);
51     void MapSignature2Deps(SCPUEUTask* task, const std::vector<const void*>& inDeps,
52         const std::vector<const void*>& outDeps, std::vector<std::pair<VersionCtx*, NestType>>& inVersions,
53         std::vector<std::pair<VersionCtx*, NestType>>& outVersions);
54 
55     fast_mutex& criticalMutex_;
56 };
57 } // namespace ffrt
58 #endif