1 /* 2 * Copyright (c) 2024 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 #include "thread_handler_singleton_impl.h" 16 17 #include <cstdint> 18 #include <functional> 19 #include <future> 20 #include <memory> 21 22 #include "nocopyable.h" 23 #include "relative_timer.h" 24 #include "thread_handler_manager.h" 25 26 #include "iam_logger.h" 27 28 #define LOG_TAG "USER_AUTH_SA" 29 30 namespace OHOS { 31 namespace UserIam { 32 namespace UserAuth { 33 using namespace OHOS; PostTask(const Task & task)34void ThreadHandlerSingletonImpl::PostTask(const Task &task) 35 { 36 RelativeTimer::GetInstance().Register(task, 0); 37 } 38 EnsureTask(const Task & task)39void ThreadHandlerSingletonImpl::EnsureTask(const Task &task) 40 { 41 std::promise<void> ensure; 42 auto callback = [&ensure]() { 43 ensure.set_value(); 44 return; 45 }; 46 PostTask(task); 47 PostTask(callback); 48 ensure.get_future().get(); 49 } 50 Suspend()51void ThreadHandlerSingletonImpl::Suspend() 52 { 53 IAM_LOGE("can not suspend"); 54 } 55 } // namespace UserAuth 56 } // namespace UserIam 57 } // namespace OHOS