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