Files
window_window_manager/utils/include/task_sequence_process.h
T
chenxinjie c58edc2d45 tdd
Signed-off-by: chenxinjie <chenxinjie11@h-partners.com>
2025-12-11 11:43:47 +08:00

42 lines
1.3 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 TASKSEQUENCEPROCESS_H
#define TASKSEQUENCEPROCESS_H
#include <mutex>
#include <queue>
#include <atomic>
namespace OHOS::Rosen {
struct TaskSequencEventInfo {
std::function<void()> taskInfo;
};
class TaskSequenceProcess {
public:
explicit TaskSequenceProcess(uint32_t maxQueueSize);
~TaskSequenceProcess();
void Notify();
void Push(const TaskSequencEventInfo& eventInfo);
void SetTaskRunningFlag(bool flag);
private:
uint32_t maxQueueSize_ {1};
std::atomic<bool> taskRunningFlag_ {false};
std::queue<TaskSequencEventInfo> taskQueue_;
std::mutex queueMutex_;
void Exec(const TaskSequencEventInfo& task);
};
}//namespace OHOS::Rosen
#endif