• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "EventQueue.h"
17 using namespace std;
18 
19 namespace OHOS::AppExecFwk {
EventTask(size_t order,Callback task,std::chrono::steady_clock::time_point targetTime)20 EventTask::EventTask(size_t order, Callback task, std::chrono::steady_clock::time_point targetTime)
21     : order(order), task(task), targetTime(targetTime)
22 {
23 }
24 
EventTask(const EventTask & other)25 EventTask::EventTask(const EventTask& other)
26     : order(other.order), task(other.task), targetTime(other.targetTime)
27 {
28 }
29 
operator =(const EventTask & other)30 EventTask& EventTask::operator=(const EventTask& other)
31 {
32     if (this != &other) {
33         order = other.order;
34         task = other.task;
35         targetTime = other.targetTime;
36     }
37     return *this;
38 }
39 
40 EventTask::~EventTask() = default;
41 
GetTask() const42 const Callback& EventTask::GetTask() const
43 {
44     return task;
45 }
46 
GetTargetTime() const47 std::chrono::steady_clock::time_point EventTask::GetTargetTime() const
48 {
49     return targetTime;
50 }
51 
operator >(const EventTask & other) const52 bool EventTask::operator>(const EventTask& other) const
53 {
54     if (targetTime == other.targetTime) {
55         return order > other.order;
56     }
57     return targetTime > other.targetTime;
58 }
59 }