1/*
2 * Copyright (c) 2024 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 "threading/sequential_impl.h"
17
18#include <base/containers/array_view.h>
19#include <core/namespace.h>
20
21CORE_BEGIN_NAMESPACE()
22using BASE_NS::array_view;
23using BASE_NS::vector;
24
25SequentialImpl::~SequentialImpl() = default;
26
27SequentialImpl::SequentialImpl(const IThreadPool::Ptr& threads) : queue_(threads) {}
28
29void SequentialImpl::Submit(uint64_t taskIdentifier, IThreadPool::ITask::Ptr&& task)
30{
31    queue_.Submit(taskIdentifier, move(task));
32}
33
34void SequentialImpl::SubmitAfter(uint64_t afterIdentifier, uint64_t taskIdentifier, IThreadPool::ITask::Ptr&& task)
35{
36    queue_.SubmitAfter(afterIdentifier, taskIdentifier, move(task));
37}
38
39void SequentialImpl::SubmitAfter(
40    array_view<const uint64_t> afterIdentifiers, uint64_t taskIdentifier, IThreadPool::ITask::Ptr&& task)
41{
42    queue_.SubmitAfter(afterIdentifiers, taskIdentifier, move(task));
43}
44
45void SequentialImpl::Execute()
46{
47    queue_.Execute();
48}
49
50void SequentialImpl::Clear()
51{
52    queue_.Clear();
53}
54
55void SequentialImpl::Destroy()
56{
57    delete this;
58}
59CORE_END_NAMESPACE()
60