1 /* 2 * Copyright (c) 2022 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 #include "task_handler.h" 17 18 #include "security_guard_log.h" 19 20 namespace OHOS::Security::SecurityGuard { 21 namespace { 22 const int THREAD_NUMS = 5; 23 const int MAX_TASK_NUMS = 1000; 24 const int MINORS_THREAD_NUMS = 1; 25 const int MINORS_MAX_TASK_NUMS = 500; 26 } 27 TaskHandler()28TaskHandler::TaskHandler() 29 { 30 SGLOGE("TaskHandler is called ."); 31 pool_.Start(THREAD_NUMS); 32 pool_.SetMaxTaskNum(MAX_TASK_NUMS); 33 minorsPool_.Start(MINORS_THREAD_NUMS); 34 minorsPool_.SetMaxTaskNum(MINORS_MAX_TASK_NUMS); 35 SGLOGE("TaskHandler end"); 36 } 37 ~TaskHandler()38TaskHandler::~TaskHandler() 39 { 40 pool_.Stop(); 41 minorsPool_.Stop(); 42 } 43 AddTask(Task & task)44void TaskHandler::AddTask(Task &task) 45 { 46 pool_.AddTask(task); 47 } 48 AddMinorsTask(Task & task)49void TaskHandler::AddMinorsTask(Task &task) 50 { 51 minorsPool_.AddTask(task); 52 } 53 }