olp-cpp-sdk 1.24.0
Loading...
Searching...
No Matches
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
31namespace olp {
32namespace client {
33
37class CORE_API PendingRequests final {
38 public:
47 bool CancelAll();
48
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
A container for requests that have not finished yet.
Definition PendingRequests.h:37
bool CancelAllAndWait()
Cancels all the pending tasks and waits for the tasks that are finalizing.
void Insert(TaskContext task_context)
Inserts the task context into the request container.
void Remove(TaskContext task_context)
Removes the task context.
size_t GetTaskCount() const
Gets the number of tasks.
bool CancelAll()
Cancels all the pending tasks.
Encapsulates the execution of an asynchronous task and invocation of a callback in a guaranteed manne...
Definition TaskContext.h:42
Rules all the other namespaces.
Definition AppleSignInProperties.h:24