|
| | BlockingQueueThread (const std::string &name, dmlc::ThreadGroup *owner, std::thread *thrd=nullptr) |
| | Constructor.
|
| |
|
| ~BlockingQueueThread () override |
| | Destructor.
|
| |
| void | request_shutdown () override |
| | Signal the thread that a shutdown is desired.
|
| |
| void | enqueue (const ObjectType &item) |
| | Enqueue and item.
|
| |
| size_t | size_approx () const |
| | Get the approximate size of the queue.
|
| |
| template<typename OnItemFunction > |
| int | run (OnItemFunction on_item_function) |
| | Thread's main queue processing function.
|
| |
| | Thread (std::string threadName, ThreadGroup *owner, std::thread *thrd=nullptr) |
| | Constructor.
|
| |
|
virtual | ~Thread () |
| | Destructor with cleanup.
|
| |
| const char * | name () const |
| | Name of the thread.
|
| |
| bool | is_current_thread () const |
| | Check if this class represents the currently running thread (self)
|
| |
| virtual bool | is_shutdown_requested () const |
| | Check whether shutdown has been requested (request_shutdown() was called)
|
| |
| bool | is_auto_remove () const |
| | Check whether the thread is set to auto-remove itself from the ThreadGroup owner when exiting.
|
| |
| void | make_joinable () |
| | Make the thread joinable (by removing the auto_remove flag)
|
| |
| bool | joinable () const |
| | Check whether the thread is joinable.
|
| |
| void | join () |
| | Thread join.
|
| |
| std::thread::id | get_id () const |
| | Get this thread's id.
|
| |
|
| 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.
|
| |
| 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.
|
| |
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
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