Blocking queue thread class.
More...
#include <thread_group.h>
|
| template<typename SecondaryFunction > |
| static bool | launch_run (std::shared_ptr< BQT > pThis, SecondaryFunction secondary_function) |
| | Launch to the 'run' function which will, in turn, call the class' 'run' function, passing it the given 'secondary_function' for it to call as needed. More...
|
| |
| template<typename StartFunction , typename ... Args> |
| static bool | launch (std::shared_ptr< Thread > pThis, bool autoRemove, StartFunction start_function, Args ...args) |
| | Launch the given Thread object. More...
|
| |
template<typename ObjectType, ObjectType quit_item>
class dmlc::BlockingQueueThread< ObjectType, quit_item >
Blocking queue thread class.
- Template Parameters
-
| ObjectType | Object type to queue |
| quit_item | Object value to signify queue shutdown (ie nullptr for pointer type is common) |
- Note
- See gtest unit test Syc.ManagedThreadLaunchQueueThread for a usage example
◆ BlockingQueueThread()
template<typename ObjectType , ObjectType quit_item>
Constructor.
- Parameters
-
| name | Name for the blockin g queue thread. Must be unique for a specific ThreadGroup |
| owner | ThreadGroup lifecycle manafger/owner |
| thrd | Optionally attach an existing stl thread object |
◆ ~BlockingQueueThread()
template<typename ObjectType , ObjectType quit_item>
◆ enqueue()
template<typename ObjectType , ObjectType quit_item>
Enqueue and item.
- Parameters
-
◆ launch_run()
template<typename ObjectType , ObjectType quit_item>
template<typename SecondaryFunction >
| static bool dmlc::BlockingQueueThread< ObjectType, quit_item >::launch_run |
( |
std::shared_ptr< BQT > |
pThis, |
|
|
SecondaryFunction |
secondary_function |
|
) |
| |
|
inlinestatic |
Launch to the 'run' function which will, in turn, call the class' 'run' function, passing it the given 'secondary_function' for it to call as needed.
- Template Parameters
-
| SecondaryFunction | Type of the secondary function for 'run' override to call as needed |
- Parameters
-
| pThis | Pointer to the managed thread to launch |
| secondary_function | secondary function for 'run' override to call as needed |
- Returns
- true if thread is launched successfully and added to the ThreadGroup
◆ request_shutdown()
template<typename ObjectType , ObjectType quit_item>
Signal the thread that a shutdown is desired.
- Note
- Since consumer doesn't necessarily get items in order, we must wait for the queue to empty. This is generally a shutdown procedure and should not be called from a performance-sensitive area
Reimplemented from dmlc::ThreadGroup::Thread.
◆ run()
template<typename ObjectType , ObjectType quit_item>
template<typename OnItemFunction >
Thread's main queue processing function.
- Template Parameters
-
| OnItemFunction | Function type to call when an item is dequeued |
- Parameters
-
| on_item_function | Function to call when an item is dequeued |
- Returns
- 0 if completed through a
quit_item, nonzero if on_item_function requested an exit
◆ size_approx()
template<typename ObjectType , ObjectType quit_item>
Get the approximate size of the queue.
- Returns
- The approximate size of the queue
The documentation for this class was generated from the following file: