Direct-BT  2.3.1
Direct-BT - Direct Bluetooth Programming.
Public Member Functions | List of all members
jau::call_on_release< UnaryFunction > Class Template Reference

Call on release allows the user to pass a function to be called at destruction of this instance. More...

#include <basic_algos.hpp>

Collaboration diagram for jau::call_on_release< UnaryFunction >:

Public Member Functions

 call_on_release (UnaryFunction release_func) noexcept
 
 ~call_on_release () noexcept
 
 call_on_release (const call_on_release &)=delete
 
call_on_releaseoperator= (const call_on_release &)=delete
 
call_on_releaseoperator= (const call_on_release &) volatile=delete
 

Detailed Description

template<class UnaryFunction>
class jau::call_on_release< UnaryFunction >

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 lili([&]() {
          is_running = false;
      });
      ...
      do some work here, which might get cancelled
      ..
  }
Template Parameters
UnaryFunctionuser provided function to be called @ dtor

Definition at line 58 of file basic_algos.hpp.

Constructor & Destructor Documentation

◆ call_on_release() [1/2]

template<class UnaryFunction >
jau::call_on_release< UnaryFunction >::call_on_release ( UnaryFunction  release_func)
inlinenoexcept

Definition at line 63 of file basic_algos.hpp.

◆ ~call_on_release()

template<class UnaryFunction >
jau::call_on_release< UnaryFunction >::~call_on_release ( )
inlinenoexcept

Definition at line 64 of file basic_algos.hpp.

◆ call_on_release() [2/2]

template<class UnaryFunction >
jau::call_on_release< UnaryFunction >::call_on_release ( const call_on_release< UnaryFunction > &  )
delete

Member Function Documentation

◆ operator=() [1/2]

template<class UnaryFunction >
call_on_release& jau::call_on_release< UnaryFunction >::operator= ( const call_on_release< UnaryFunction > &  ) volatile
delete

◆ operator=() [2/2]

template<class UnaryFunction >
call_on_release& jau::call_on_release< UnaryFunction >::operator= ( const call_on_release< UnaryFunction > &  )
delete

The documentation for this class was generated from the following file: