• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 #ifndef HIAPPEVENT_FRAMEWORKS_NATIVE_LIB_HIAPPEVENT_INCLUDE_HIAPPEVENT_FFRT_H
16 #define HIAPPEVENT_FRAMEWORKS_NATIVE_LIB_HIAPPEVENT_INCLUDE_HIAPPEVENT_FFRT_H
17 
18 #include "ffrt.h"
19 
20 namespace OHOS {
21 namespace HiviewDFX {
22 namespace HiAppEvent {
23 FFRT_C_API ffrt_error_t ffrt_submit_base_nb(ffrt_function_header_t* f, const ffrt_deps_t* in_deps,
24     const ffrt_deps_t* out_deps, const ffrt_task_attr_t* attr);
25 
26 static inline ffrt_error_t Submit(std::function<void()>&& func, std::initializer_list<ffrt::dependence> in_deps,
27     std::initializer_list<ffrt::dependence> out_deps, const ffrt::task_attr& attr = {})
28 {
29     ffrt_deps_t in{static_cast<uint32_t>(in_deps.size()), in_deps.begin()};
30     ffrt_deps_t out{static_cast<uint32_t>(out_deps.size()), out_deps.begin()};
31     return ffrt_submit_base_nb(ffrt::create_function_wrapper(std::move(func)), &in, &out, &attr);
32 }
33 } // namespace HiAppEvent
34 } // namespace HiviewDFX
35 } // namespace OHOS
36 #endif // HIAPPEVENT_FRAMEWORKS_NATIVE_LIB_HIAPPEVENT_INCLUDE_HIAPPEVENT_FFRT_H
37