Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions olp-cpp-sdk-core/include/olp/core/client/CancellationToken.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2021 HERE Europe B.V.
* Copyright (C) 2019-2026 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -51,7 +51,7 @@ class CORE_API CancellationToken {
void Cancel() const;

private:
CancelFuncType func_;
mutable CancelFuncType func_;
};

} // namespace client
Expand Down
8 changes: 5 additions & 3 deletions olp-cpp-sdk-core/src/client/CancellationToken.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2021 HERE Europe B.V.
* Copyright (C) 2019-2026 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,8 +26,10 @@ CancellationToken::CancellationToken(CancelFuncType func)
: func_(std::move(func)) {}

void CancellationToken::Cancel() const {
if (func_) {
func_();
CancelFuncType func;
std::swap(func_, func);
if (func) {
func();
}
}

Expand Down
Loading