|
cppthread 1.1.16
C++ Thread Library
|
Class used to manage the worker and worker thread. More...
Public Types | |
| typedef std::shared_ptr< worker_thread_t > | pointer_t |
| The shared pointer type to a worker thread. | |
| typedef std::vector< pointer_t > | vector_t |
| The vector of shared pointers. | |
Public Member Functions | |
| worker_thread_t (std::string const &name, std::size_t i, typename worker_fifo_t::pointer_t in, typename worker_fifo_t::pointer_t out, A... args) | |
| The constructor of a worker thread. | |
| W & | get_worker () |
| Retrieve a pointer to the working in this worker thread. | |
| W const & | get_worker () const |
| Retrieve the worker when the worker thread is constant. | |
Private Attributes | |
| thread::pointer_t | f_thread |
| The thread which manages the worker. | |
| W | f_worker |
| The worker, which is a runner. | |
This class creates a worker thread, it adds it to a thread, and it starts the thread. It is here so we have a single list of worker threads.
| cppthread::pool< W, A >::worker_thread_t::pointer_t |
When the pool creates worker threads, it allocates them as shared pointers and saves them in a vector.
| cppthread::pool< W, A >::worker_thread_t::vector_t |
|
inline |
A worker thread is a thread and a runner manager.
The name is used by the thread. For the worker, we append " (worker #...)" to the name and assign that to the worker. This way, we can distinguish each worker properly.
The i parameter is the index representing the worker number. It has no special anything otherwise.
The input fifo (in) must be defined on construction. It gets passed to all the workers so they all can wait for new workload messages.
The output fifo (out) is optional. If you use the item_with_predicate with actual predicates, remember that a workload needs to be released for the predicate to become true. Adding them to another fifo may prevent this pool from processing additional workloads for long periods of time.
| [in] | name | The name of the thread and worker. |
| [in] | i | The index of this worker thread. |
| [in] | in | The input fifo where workloads are sent. |
| [in] | out | The output fifo where workloads are forwarded once worked on. This parameter is optional (you can use a nullptr. |
| [in] | args | Additional arguments to construct the worker threads runners (as per your type W). |
Definition at line 61 of file pool.h.
References cppthread::pool< W, A >::worker_thread_t::f_thread, and cppthread::to_string().

|
inline |
This function is used to access the worker of the worker_thread_t object.
Definition at line 76 of file pool.h.
References cppthread::pool< W, A >::worker_thread_t::f_worker.
|
inline |
This function is used to access the worker of the worker_thread_t object.
Definition at line 81 of file pool.h.
References cppthread::pool< W, A >::worker_thread_t::f_worker.
|
private |
This object is a thread used to manage the corresponding worker thread which is the operating system thread.
Definition at line 88 of file pool.h.
Referenced by cppthread::pool< W, A >::worker_thread_t::worker_thread_t().
|
private |
The work is a runner of the type you decide through W. It gets initialized and started when you create the pool. It immediately listens on the input fifo which can already have workload items as required.
Definition at line 87 of file pool.h.
Referenced by cppthread::pool< W, A >::worker_thread_t::get_worker(), and cppthread::pool< W, A >::worker_thread_t::get_worker().
This document is part of the Snap! Websites Project.
Copyright by Made to Order Software Corp.