Skip to content

Commit 3043009

Browse files
meravingen123andescu
authored andcommitted
Release resources in TaskContext before notifying user.
Resolves: OLPEDGE-1005 Signed-off-by: Serhii Lozynskyi <[email protected]>
1 parent 208d71b commit 3043009

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

olp-cpp-sdk-core/include/olp/core/client/TaskContext.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
#include <atomic>
2323
#include <mutex>
2424

25+
#include <olp/core/client/ApiError.h>
26+
#include <olp/core/client/ApiResponse.h>
27+
#include <olp/core/client/CancellationContext.h>
28+
#include <olp/core/client/CancellationToken.h>
2529
#include <olp/core/client/Condition.h>
26-
#include "olp/core/client/ApiError.h"
27-
#include "olp/core/client/ApiResponse.h"
28-
#include "olp/core/client/CancellationContext.h"
29-
#include "olp/core/client/CancellationToken.h"
3030

3131
namespace olp {
3232
namespace client {
@@ -161,6 +161,11 @@ class TaskContext {
161161
callback(std::move(user_response));
162162
}
163163

164+
// Resources needs to be released before notification, else lambas would
165+
// have captured resources like network or TaskScheduler
166+
function = nullptr;
167+
callback = nullptr;
168+
164169
condition_.Notify();
165170

166171
state_.store(State::COMPLETED);

0 commit comments

Comments
 (0)