1 /*
2 * Copyright (c) 2023-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
16 #include "status_mgr_center/form_status_queue.h"
17 #include "fms_log_wrapper.h"
18
19 namespace OHOS {
20 namespace AppExecFwk {
21 namespace {
22 const std::string FORM_STATUS_QUEUE = "FormStatusQueue";
23 }
FormStatusQueue()24 FormStatusQueue::FormStatusQueue()
25 {
26 serialQueue_ = std::make_shared<FormSerialQueue>(FORM_STATUS_QUEUE.c_str());
27 HILOG_INFO("create FormStatusQueue");
28 }
29
~FormStatusQueue()30 FormStatusQueue::~FormStatusQueue()
31 {
32 HILOG_INFO("destroy FormStatusQueue");
33 }
34
ScheduleTask(uint64_t ms,std::function<void ()> func)35 bool FormStatusQueue::ScheduleTask(uint64_t ms, std::function<void()> func)
36 {
37 HILOG_INFO("call");
38 if (serialQueue_ == nullptr) {
39 HILOG_ERROR("null serialQueue_");
40 return false;
41 }
42
43 return serialQueue_->ScheduleTask(ms, func);
44 }
45
ScheduleDelayTask(const std::pair<int64_t,int64_t> & eventMsg,uint64_t ms,std::function<void ()> func)46 bool FormStatusQueue::ScheduleDelayTask(
47 const std::pair<int64_t, int64_t> &eventMsg, uint64_t ms, std::function<void()> func)
48 {
49 HILOG_INFO("call");
50 if (serialQueue_ == nullptr) {
51 HILOG_ERROR("null serialQueue_");
52 return false;
53 }
54
55 return serialQueue_->ScheduleDelayTask(eventMsg, ms, func);
56 }
57
CancelDelayTask(const std::pair<int64_t,int64_t> & eventMsg)58 bool FormStatusQueue::CancelDelayTask(const std::pair<int64_t, int64_t> &eventMsg)
59 {
60 HILOG_INFO("call");
61 if (serialQueue_ == nullptr) {
62 HILOG_ERROR("null serialQueue_");
63 return false;
64 }
65
66 return serialQueue_->CancelDelayTask(eventMsg);
67 }
68 } // namespace AppExecFwk
69 } // namespace OHOS
70