mirror of
https://github.com/openharmony/window_window_manager.git
synced 2026-08-25 00:03:00 -04:00
c4dedb6fd1
Signed-off-by: chenxinjie253 <chenxinjie11@h-partners.com>
49 lines
1.5 KiB
C++
49 lines
1.5 KiB
C++
/*
|
|
* Copyright (c) 2025 Huawei Device Co., Ltd.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#ifndef TASK_SEQUENCE_PROCESS_H
|
|
#define TASK_SEQUENCE_PROCESS_H
|
|
#include <mutex>
|
|
#include <queue>
|
|
#include <atomic>
|
|
#include "system_timer.h"
|
|
|
|
namespace OHOS::Rosen {
|
|
|
|
class TaskSequenceProcess {
|
|
public:
|
|
explicit TaskSequenceProcess(uint32_t maxQueueSize, uint64_t maxTimeInterval);
|
|
~TaskSequenceProcess();
|
|
void AddTask(const std::function<void()>& task);
|
|
void FinishTask();
|
|
void CreatSysTimer();
|
|
private:
|
|
uint32_t maxQueueSize_ {1};
|
|
uint64_t maxTimeInterval_ {1000};
|
|
uint64_t taskTimerId_ {0};
|
|
std::queue<std::function<void()>> taskQueue_;
|
|
std::mutex queueMutex_;
|
|
std::mutex timerMutex_;
|
|
std::atomic<bool> taskRunningFlag_ {false};
|
|
WindowSysTimer TaskTimer;
|
|
std::function<void()> PopFromQueue();
|
|
void PushToQueue(const std::function<void()>& task);
|
|
void ExecTask();
|
|
void DestroySysTimer();
|
|
void StartSysTimer();
|
|
void StopSysTimer();
|
|
};
|
|
} //namespace OHOS::Rosen
|
|
#endif |