Skip to content

Commit

Permalink
Improve scope_exit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackarain committed Sep 6, 2023
1 parent b0f6005 commit 9c56064
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions utils/include/utils/scoped_exit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ class scoped_exit
f_();
}

inline void operator()()
{
if (stop_token_)
return;

stop_token_ = true;

f_();
}

inline void cancel()
{
stop_token_ = true;
Expand Down

0 comments on commit 9c56064

Please sign in to comment.