libeblearntools
ebl::thread Class Reference

A thread abstraction class. More...

#include <thread.h>

Inheritance diagram for ebl::thread:
ebl::detection_thread< Tnet > ebl::fprop_thread< Tnet > ebl::tracking_thread< Tnet >

List of all members.

Public Member Functions

 thread (mutex *outmutex=NULL, const char *name="Thread", bool sync=true)
int start ()
 Start the thread.
void stop (long wait_seconds=0)
void ask_stop ()
bool finished ()
 Return true if thread has finished executing.
std::string & name ()
 Return name of this thread.
std::ostream & get_mout ()
 Return a reference this thread's output stream.
std::ostream & get_merr ()
 Return a reference this thread's output error stream.

Protected Member Functions

void run ()
virtual void execute ()=0

Static Protected Member Functions

static void * entrypoint (void *pthis)

Protected Attributes

bool _stop
std::string _name
mutex_ostream mutout
 Name of this thread.
mutex_ostream muterr
ostream & mout
ostream & merr

Detailed Description

A thread abstraction class.


Constructor & Destructor Documentation

ebl::thread::thread ( mutex outmutex = NULL,
const char *  name = "Thread",
bool  sync = true 
)
Parameters:
outmutexA mutex used to synchronize threads outputs/ To synchronize all threads, give the same mutex to each of them.
syncIf true, synchronize outputs between threads, using outmutex, otherwise use regular unsynced outputs.

Member Function Documentation

void ebl::thread::ask_stop ( )

Tell the thread it should stop. The thread might be busy finishing some task, so this only tells it to quit when it is finished. One can check if the thread is finished with the finished() method.

void ebl::thread::stop ( long  wait_seconds = 0)

Stop the thread. If wait_seconds is zero, stop the thread right now, otherwise wait until the thread has finished its current task or force it to exit if it's not finished after wait_seconds seconds.


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