Maestro 0.3.11
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
Utils::WorkerThread< ThreadsPool, Job > Class Template Reference

WorkerThread class for a thread in a threads pool. More...

#include <WorkerThread.h>

Inheritance diagram for Utils::WorkerThread< ThreadsPool, Job >:
Collaboration diagram for Utils::WorkerThread< ThreadsPool, Job >:

Public Member Functions

 WorkerThread (ThreadsPool *threadsPool)
 Construct a new Worker Thread object.
 ~WorkerThread ()
 Destroy the Worker Thread object.
void Abandon ()
 Forget a thread that does not exist any more.
void Join ()
 Join the thread.
void SetStopUnlocked ()
 Set the stop flag without locking it.
void Start ()
 Start the thread.
void Stop ()
 Stop the thread.

Detailed Description

template<class ThreadsPool, class Job>
class Utils::WorkerThread< ThreadsPool, Job >

WorkerThread class for a thread in a threads pool.

A thread that is used in a threads pool, executing jobs.

Template Parameters
ThreadsPoolThe threads pool class.
JobThe job class/type.
See also
ThreadsPool

Definition at line 34 of file WorkerThread.h.

Constructor & Destructor Documentation

◆ WorkerThread()

template<class ThreadsPool, class Job>
Utils::WorkerThread< ThreadsPool, Job >::WorkerThread ( ThreadsPool * threadsPool)
inlineexplicit

Construct a new Worker Thread object.

Constructs a new Worker Thread object, associated with the given threads pool. The thread is started immediately.

Parameters
threadsPoolThe threads pool that this thread belongs to.

Definition at line 45 of file WorkerThread.h.

◆ ~WorkerThread()

template<class ThreadsPool, class Job>
Utils::WorkerThread< ThreadsPool, Job >::~WorkerThread ( )
inline

Destroy the Worker Thread object.

Destroys the Worker Thread object, stopping the thread if it is still running.

Definition at line 56 of file WorkerThread.h.

Member Function Documentation

◆ Abandon()

template<class ThreadsPool, class Job>
void Utils::WorkerThread< ThreadsPool, Job >::Abandon ( )
inline

Forget a thread that does not exist any more.

Used in a child process after fork(), where the parent's threads are gone: the handle is neither joined nor detached, and is leaked because destroying a joinable std::thread terminates the process.

Definition at line 125 of file WorkerThread.h.

◆ Join()

template<class ThreadsPool, class Job>
void Utils::WorkerThread< ThreadsPool, Job >::Join ( )
inline

Join the thread.

Joins the thread if it is joinable, waiting for it to finish.

Definition at line 112 of file WorkerThread.h.

Referenced by Utils::WorkerThread< ThreadsPool< Job >, Job >::Stop().

◆ SetStopUnlocked()

template<class ThreadsPool, class Job>
void Utils::WorkerThread< ThreadsPool, Job >::SetStopUnlocked ( )
inline

Set the stop flag without locking it.

Sets the stop flag to true without locking the threads pool mutex.

Definition at line 102 of file WorkerThread.h.

◆ Start()

template<class ThreadsPool, class Job>
void Utils::WorkerThread< ThreadsPool, Job >::Start ( )
inline

Start the thread.

Starts the thread if not already started.

Definition at line 66 of file WorkerThread.h.

◆ Stop()

template<class ThreadsPool, class Job>
void Utils::WorkerThread< ThreadsPool, Job >::Stop ( )
inline

Stop the thread.

Stops the thread if it is running, and waits for it to finish.

Definition at line 83 of file WorkerThread.h.

Referenced by Utils::WorkerThread< ThreadsPool< Job >, Job >::~WorkerThread().


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