Public Member Functions | Private Attributes | List of all members
tesseract_common::Timer Class Reference

A timer which calls a callback every interval on a separate thread. More...

#include <timer.h>

Public Member Functions

Timeroperator= (const Timer &)=delete
 
Timeroperator= (Timer &&)=delete
 
void start (const std::function< void()> &callback, std::chrono::steady_clock::duration interval)
 Start the timer with a callback function and a std::chrono::duration interval. More...
 
void stop ()
 Stop the timer. More...
 
 Timer ()=default
 
 Timer (const Timer &)=delete
 
 Timer (Timer &&)=delete
 
 ~Timer ()
 

Private Attributes

std::atomic< bool > running_ { false }
 
std::thread timer_thread_
 

Detailed Description

A timer which calls a callback every interval on a separate thread.

Definition at line 40 of file timer.h.

Constructor & Destructor Documentation

◆ Timer() [1/3]

tesseract_common::Timer::Timer ( )
default

◆ ~Timer()

tesseract_common::Timer::~Timer ( )

Definition at line 31 of file timer.cpp.

◆ Timer() [2/3]

tesseract_common::Timer::Timer ( const Timer )
delete

◆ Timer() [3/3]

tesseract_common::Timer::Timer ( Timer &&  )
delete

Member Function Documentation

◆ operator=() [1/2]

Timer& tesseract_common::Timer::operator= ( const Timer )
delete

◆ operator=() [2/2]

Timer& tesseract_common::Timer::operator= ( Timer &&  )
delete

◆ start()

void tesseract_common::Timer::start ( const std::function< void()> &  callback,
std::chrono::steady_clock::duration  interval 
)

Start the timer with a callback function and a std::chrono::duration interval.

Parameters
callbackThe callback called every time the timer expires
intervalThe interval at which the timer triggers

Definition at line 33 of file timer.cpp.

◆ stop()

void tesseract_common::Timer::stop ( )

Stop the timer.

Definition at line 46 of file timer.cpp.

Member Data Documentation

◆ running_

std::atomic<bool> tesseract_common::Timer::running_ { false }
private

Definition at line 61 of file timer.h.

◆ timer_thread_

std::thread tesseract_common::Timer::timer_thread_
private

Definition at line 62 of file timer.h.


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


tesseract_common
Author(s): Levi Armstrong
autogenerated on Sun May 18 2025 03:01:41