11/*
2- * Copyright (C) 2019-2021 HERE Europe B.V.
2+ * Copyright (C) 2019-2026 HERE Europe B.V.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -29,13 +29,25 @@ namespace {
2929constexpr auto kLogTag = " PendingRequests" ;
3030}
3131
32+ PendingRequests::~PendingRequests () {
33+ #ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL
34+ OLP_SDK_LOG_INFO_F (kLogTag , " Destructor: pending task count=%zu, this=%p" ,
35+ GetTaskCount (), static_cast <void *>(this ));
36+ #endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL
37+ }
38+
3239bool PendingRequests::CancelAll () {
3340 ContextMap contexts;
3441 {
3542 std::lock_guard<std::mutex> lock (task_contexts_lock_);
3643 contexts = task_contexts_;
3744 }
3845
46+ #ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL
47+ OLP_SDK_LOG_INFO_F (kLogTag , " CancelAll: pending task count=%zu, this=%p" ,
48+ contexts.size (), static_cast <void *>(this ));
49+ #endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL
50+
3951 for (auto context : contexts) {
4052 context.CancelToken ().Cancel ();
4153 }
@@ -52,23 +64,70 @@ bool PendingRequests::CancelAllAndWait() {
5264 contexts = std::move (task_contexts_);
5365 }
5466
67+ #ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL
68+ OLP_SDK_LOG_INFO_F (
69+ kLogTag , " CancelAllAndWait: started, pending task count=%zu, this=%p" ,
70+ contexts.size (), static_cast <void *>(this ));
71+ #endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL
72+
5573 for (auto context : contexts) {
5674 if (!context.BlockingCancel ()) {
57- OLP_SDK_LOG_WARNING (kLogTag , " Timeout, when waiting on BlockingCancel" );
75+ OLP_SDK_LOG_WARNING_F (kLogTag ,
76+ " Timeout, when waiting on BlockingCancel, this=%p" ,
77+ static_cast <void *>(this ));
5878 }
5979 }
6080
81+ #ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL
82+ OLP_SDK_LOG_INFO_F (kLogTag , " CancelAllAndWait: finished, this=%p" ,
83+ static_cast <void *>(this ));
84+ #endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL
85+
6186 return true ;
6287}
6388
6489void PendingRequests::Insert (TaskContext task_context) {
65- std::lock_guard<std::mutex> lock (task_contexts_lock_);
66- task_contexts_.insert (task_context);
90+ #ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL
91+ size_t size = 0 ;
92+ #endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL
93+
94+ {
95+ std::lock_guard<std::mutex> lock (task_contexts_lock_);
96+ task_contexts_.insert (task_context);
97+
98+ #ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL
99+ size = task_contexts_.size ();
100+ #endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL
101+ }
102+
103+ #ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL
104+ OLP_SDK_LOG_INFO_F (
105+ kLogTag ,
106+ " Insert: a new task context inserted. Pending task count=%zu, this=%p" ,
107+ size, static_cast <void *>(this ));
108+ #endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL
67109}
68110
69111void PendingRequests::Remove (TaskContext task_context) {
70- std::lock_guard<std::mutex> lock (task_contexts_lock_);
71- task_contexts_.erase (task_context);
112+ #ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL
113+ size_t size = 0 ;
114+ #endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL
115+
116+ {
117+ std::lock_guard<std::mutex> lock (task_contexts_lock_);
118+ task_contexts_.erase (task_context);
119+
120+ #ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL
121+ size = task_contexts_.size ();
122+ #endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL
123+ }
124+
125+ #ifdef LOGGING_ENABLE_EXTENDED_INFO_LEVEL
126+ OLP_SDK_LOG_INFO_F (
127+ kLogTag ,
128+ " Remove: a task context removed. Pending task count=%zu, this=%p" , size,
129+ static_cast <void *>(this ));
130+ #endif // LOGGING_ENABLE_EXTENDED_INFO_LEVEL
72131}
73132
74133size_t PendingRequests::GetTaskCount () const {
0 commit comments