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 JS_CONCURRENT_MODULE_TASKPOOL_TASK_GROUP_H 17 #define JS_CONCURRENT_MODULE_TASKPOOL_TASK_GROUP_H 18 19 #include <list> 20 21 #include "task.h" 22 #include "task_manager.h" 23 24 namespace Commonlibrary::Concurrent::TaskPoolModule { 25 class TaskGroup { 26 public: 27 static napi_value TaskGroupConstructor(napi_env env, napi_callback_info cbinfo); 28 static napi_value AddTask(napi_env env, napi_callback_info cbinfo); 29 30 private: 31 TaskGroup() = delete; 32 ~TaskGroup() = delete; 33 TaskGroup(const TaskGroup &) = delete; 34 TaskGroup& operator=(const TaskGroup &) = delete; 35 TaskGroup(TaskGroup &&) = delete; 36 TaskGroup& operator=(TaskGroup &&) = delete; 37 38 static void Destructor(napi_env env, void* nativeObject, void* finalize); 39 }; 40 41 struct GroupInfo { 42 napi_deferred deferred = nullptr; 43 uint32_t groupId = 0; 44 uint32_t taskNum = 0; 45 uint32_t finishedTask = 0; 46 std::list<uint32_t> executeIds {}; 47 napi_ref resArr = nullptr; 48 }; 49 50 } // namespace Commonlibrary::Concurrent::TaskPoolModule 51 #endif // JS_CONCURRENT_MODULE_TASKPOOL_TASK_GROUP_H