Android-cuttlefish cvd tool
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
cuttlefish::ThreadLooper Class Reference

#include <thread_looper.h>

Classes

struct  Event
 

Public Types

typedef std::function< void()> Callback
 
typedef int32_t Serial
 

Public Member Functions

 ThreadLooper ()
 
 ~ThreadLooper ()
 
 ThreadLooper (const ThreadLooper &)=delete
 
ThreadLooperoperator= (const ThreadLooper &)=delete
 
Serial Post (Callback cb)
 
Serial Post (Callback cb, std::chrono::steady_clock::duration delay)
 
void Stop ()
 
bool CancelSerial (Serial serial)
 

Private Member Functions

void ThreadLoop ()
 
void Insert (const Event &event)
 

Private Attributes

bool stopped_
 
std::thread looper_thread_
 
std::mutex lock_
 
std::condition_variable cond_
 
std::deque< Eventqueue_
 
std::atomic< Serialnext_serial_
 

Member Typedef Documentation

◆ Callback

typedef std::function<void()> cuttlefish::ThreadLooper::Callback

◆ Serial

Constructor & Destructor Documentation

◆ ThreadLooper() [1/2]

cuttlefish::ThreadLooper::ThreadLooper ( )

◆ ~ThreadLooper()

cuttlefish::ThreadLooper::~ThreadLooper ( )

◆ ThreadLooper() [2/2]

cuttlefish::ThreadLooper::ThreadLooper ( const ThreadLooper )
delete

Member Function Documentation

◆ CancelSerial()

bool cuttlefish::ThreadLooper::CancelSerial ( Serial  serial)

◆ Insert()

void cuttlefish::ThreadLooper::Insert ( const Event event)
private

◆ operator=()

ThreadLooper & cuttlefish::ThreadLooper::operator= ( const ThreadLooper )
delete

◆ Post() [1/2]

ThreadLooper::Serial cuttlefish::ThreadLooper::Post ( Callback  cb)

◆ Post() [2/2]

ThreadLooper::Serial cuttlefish::ThreadLooper::Post ( Callback  cb,
std::chrono::steady_clock::duration  delay 
)

◆ Stop()

void cuttlefish::ThreadLooper::Stop ( )

◆ ThreadLoop()

void cuttlefish::ThreadLooper::ThreadLoop ( )
private

Member Data Documentation

◆ cond_

std::condition_variable cuttlefish::ThreadLooper::cond_
private

◆ lock_

std::mutex cuttlefish::ThreadLooper::lock_
private

◆ looper_thread_

std::thread cuttlefish::ThreadLooper::looper_thread_
private

◆ next_serial_

std::atomic<Serial> cuttlefish::ThreadLooper::next_serial_
private

◆ queue_

std::deque<Event> cuttlefish::ThreadLooper::queue_
private

◆ stopped_

bool cuttlefish::ThreadLooper::stopped_
private

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