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 
21 CORE_BEGIN_NAMESPACE()
22 using BASE_NS::array_view;
23 using BASE_NS::vector;
24 
25 SequentialImpl::~SequentialImpl() = default;
26 
SequentialImpl(const IThreadPool::Ptr & threads)27 SequentialImpl::SequentialImpl(const IThreadPool::Ptr& threads) : queue_(threads) {}
28 
Submit(uint64_t taskIdentifier,IThreadPool::ITask::Ptr && task)29 void SequentialImpl::Submit(uint64_t taskIdentifier, IThreadPool::ITask::Ptr&& task)
30 {
31     queue_.Submit(taskIdentifier, move(task));
32 }
33 
SubmitAfter(uint64_t afterIdentifier,uint64_t taskIdentifier,IThreadPool::ITask::Ptr && task)34 void SequentialImpl::SubmitAfter(uint64_t afterIdentifier, uint64_t taskIdentifier, IThreadPool::ITask::Ptr&& task)
35 {
36     queue_.SubmitAfter(afterIdentifier, taskIdentifier, move(task));
37 }
38 
SubmitAfter(array_view<const uint64_t> afterIdentifiers,uint64_t taskIdentifier,IThreadPool::ITask::Ptr && task)39 void 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 
Execute()45 void SequentialImpl::Execute()
46 {
47     queue_.Execute();
48 }
49 
Clear()50 void SequentialImpl::Clear()
51 {
52     queue_.Clear();
53 }
54 
Destroy()55 void SequentialImpl::Destroy()
56 {
57     delete this;
58 }
59 CORE_END_NAMESPACE()
60