olp-cpp-sdk
1.22.0
olp-cpp-sdk-core
include
olp
core
client
PendingRequests.h
1
/*
2
* Copyright (C) 2019-2021 HERE Europe B.V.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*
16
* SPDX-License-Identifier: Apache-2.0
17
* License-Filename: LICENSE
18
*/
19
20
#pragma once
21
22
#include <memory>
23
#include <mutex>
24
#include <unordered_map>
25
#include <unordered_set>
26
#include <vector>
27
28
#include <olp/core/client/CancellationToken.h>
29
#include <olp/core/client/TaskContext.h>
30
31
namespace
olp
{
32
namespace
client {
33
37
class
CORE_API
PendingRequests
final {
38
public
:
47
bool
CancelAll
();
48
55
bool
CancelAllAndWait
();
56
62
void
Insert
(
TaskContext
task_context);
63
69
void
Remove
(
TaskContext
task_context);
70
76
size_t
GetTaskCount
()
const
;
77
78
private
:
79
using
ContextMap = std::unordered_set<TaskContext, TaskContextHash>;
80
ContextMap task_contexts_;
81
mutable
std::mutex task_contexts_lock_;
82
};
83
84
}
// namespace client
85
}
// namespace olp
olp::client::PendingRequests
A container for requests that have not finished yet.
Definition:
PendingRequests.h:37
olp::client::PendingRequests::CancelAllAndWait
bool CancelAllAndWait()
Cancels all the pending tasks and waits for the tasks that are finalizing.
olp::client::PendingRequests::Insert
void Insert(TaskContext task_context)
Inserts the task context into the request container.
olp::client::PendingRequests::Remove
void Remove(TaskContext task_context)
Removes the task context.
olp::client::PendingRequests::GetTaskCount
size_t GetTaskCount() const
Gets the number of tasks.
olp::client::PendingRequests::CancelAll
bool CancelAll()
Cancels all the pending tasks.
olp::client::TaskContext
Encapsulates the execution of an asynchronous task and invocation of a callback in a guaranteed manne...
Definition:
TaskContext.h:42
olp
Rules all the other namespaces.
Definition:
AppleSignInProperties.h:24
Generated by
1.9.1