• 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 
16 #include "form_mgr/form_mgr_queue.h"
17 #include "fms_log_wrapper.h"
18 
19 namespace OHOS {
20 namespace AppExecFwk {
21 namespace {
22 const std::string FORM_MGR_QUEUE = "FormMgrQueue";
23 }
FormMgrQueue()24 FormMgrQueue::FormMgrQueue()
25 {
26     serialQueue_ = std::make_shared<FormSerialQueue>(FORM_MGR_QUEUE.c_str());
27     HILOG_INFO("create FormMgrQueue");
28 }
29 
~FormMgrQueue()30 FormMgrQueue::~FormMgrQueue()
31 {
32     HILOG_INFO("destroy FormMgrQueue");
33 }
34 
ScheduleTask(uint64_t ms,std::function<void ()> func)35 bool FormMgrQueue::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,uint32_t ms,std::function<void ()> func)46 void FormMgrQueue::ScheduleDelayTask(const std::pair<int64_t, int64_t> &eventMsg,
47     uint32_t ms, std::function<void()> func)
48 {
49     HILOG_INFO("call");
50     if (serialQueue_ == nullptr) {
51         HILOG_ERROR("null serialQueue_");
52         return;
53     }
54 
55     serialQueue_->ScheduleDelayTask(eventMsg, ms, func);
56 }
57 
CancelDelayTask(const std::pair<int64_t,int64_t> & eventMsg)58 void FormMgrQueue::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;
64     }
65 
66     serialQueue_->CancelDelayTask(eventMsg);
67 }
68 } // namespace AppExecFwk
69 } // namespace OHOS