ILLIXR: Illinois Extended Reality Testbed
Public Types | Public Member Functions | List of all members
ILLIXR::managed_thread Class Reference

An object that manages a std::thread; it joins and exits when the object gets destructed. More...

#include <managed_thread.hpp>

Public Types

enum class  state { nonstartable , startable , running , stopped }
 Possible states for a managed_thread.
 

Public Member Functions

 managed_thread () noexcept=default
 Constructs a non-startable thread.
 
 managed_thread (std::function< void()> body, std::function< void()> on_start=std::function< void()>{}, std::function< void()> on_stop=std::function< void()>{}) noexcept
 Constructs a startable thread. More...
 
 ~managed_thread () noexcept
 Stops a thread, if necessary.
 
state get_state ()
 
void start ()
 Moves a managed_thread from startable to running.
 
void stop ()
 Moves a managed_thread from running to stopped.
 

Detailed Description

An object that manages a std::thread; it joins and exits when the object gets destructed.

Constructor & Destructor Documentation

◆ managed_thread()

ILLIXR::managed_thread::managed_thread ( std::function< void()>  body,
std::function< void()>  on_start = std::function<void()>{},
std::function< void()>  on_stop = std::function<void()>{} 
)
inlineexplicitnoexcept

Constructs a startable thread.

on_stop is called once (if present) on_start is called as the thread is joining body is called in a tight loop


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