jaulib v1.3.0
Jau Support Library (C++, Java, ..)
|
Call on release allows the user to pass a function to be called at destruction of this instance. More...
#include <basic_algos.hpp>
Public Member Functions | |
call_on_release (const call_on_release &)=delete | |
call_on_release (UnaryFunction release_func) noexcept | |
~call_on_release () noexcept | |
bool | is_released () const noexcept |
Query whethr the resource has been orderly released. More... | |
call_on_release & | operator= (const call_on_release &) volatile=delete |
call_on_release & | operator= (const call_on_release &)=delete |
void | set_released () noexcept |
Mark the resource being orderly released, release_func() will not be called and use after free avoided. More... | |
Call on release allows the user to pass a function to be called at destruction of this instance.
One goal was to provide a thread exit cleanup facility, setting a 'is_running' flag to false when the thread exists normally or abnormally.
jau::relaxed_atomic_bool is_running = true; void some_thread_func() { thread_local jau::call_on_release thread_cleanup([&]() { is_running = false; }); ... do some work here, which might get cancelled .. thread_cleanup.set_released(); // mark orderly release }
UnaryFunction | user provided function to be called @ dtor |
Definition at line 65 of file basic_algos.hpp.
|
inlinenoexcept |
Definition at line 71 of file basic_algos.hpp.
|
inlinenoexcept |
Definition at line 73 of file basic_algos.hpp.
|
delete |
|
delete |
|
delete |
|
inlinenoexcept |
Mark the resource being orderly released, release_func()
will not be called and use after free avoided.
Definition at line 81 of file basic_algos.hpp.
|
inlinenoexcept |
Query whethr the resource has been orderly released.
Definition at line 83 of file basic_algos.hpp.