NVIDIA DeepStream SDK API Reference

9.2 Release
NvTrackerMultiThreadWorker< T > Class Template Reference

Detailed Description

template<typename T>
class NvTrackerMultiThreadWorker< T >

Multi-threaded producer-consumer queue to perform some task.

Definition at line 343 of file sources/libs/nvmultiobjecttracker/include/modules/NvMultiObjectTracker/NvMultiObjectTracker_common.hpp.

Public Member Functions

 NvTrackerMultiThreadWorker ()
 Initialize an empty worker queue. More...
 
 ~NvTrackerMultiThreadWorker ()
 Stop and join all persistent worker threads. More...
 
void initialize (const uint numThreads, std::function< void(T)> funcPerThread)
 Launch all worker threads and worker function. More...
 
void submitInput (T inData)
 Submit association input data to queue in main thread. More...
 
void waitToFinish ()
 Wait all worker threads to finish in main thread. More...
 
void threadLoopFunc ()
 Process queued jobs until the worker receives a deinitialization signal. More...
 
bool isInitialized ()
 Report whether the worker queue is initialized. More...
 
 NvTrackerMultiThreadWorker ()
 Initialize an empty worker queue. More...
 
 ~NvTrackerMultiThreadWorker ()
 Stop and join all persistent worker threads. More...
 
void initialize (const uint numThreads, std::function< void(T)> funcPerThread)
 Launch all worker threads and worker function. More...
 
void submitInput (T inData)
 Submit association input data to queue in main thread. More...
 
void waitToFinish ()
 Wait all worker threads to finish in main thread. More...
 
void threadLoopFunc ()
 Process queued jobs until the worker receives a deinitialization signal. More...
 
bool isInitialized ()
 Report whether the worker queue is initialized. More...
 

Data Fields

bool m_isInit
 Indicates whether the worker has been initialized. More...
 
std::mutex m_inputLock
 Lock associated with input queue. More...
 
std::mutex m_outputLock
 Lock associated with output. More...
 
std::condition_variable m_cond4In
 Condition variable associated with the input queue. More...
 
std::condition_variable m_cond4Out
 Condition variable associated with the output. More...
 
std::queue< T > m_inputQueue
 Queue for input. More...
 
std::vector< std::thread > m_threadList
 Persistent threads over batches. More...
 
bool m_persistThreadRunning
 Whether associate persistent threads should keep running; set false if receive deinit signal. More...
 
uint m_submittedJobCnt
 Keep track of how many tasks are submitted. More...
 
uint m_finishedJobCnt
 Keep track of how many tasks are finished. More...
 
std::function< void(T)> m_funcPerThread
 Data processing function in each worker thread. More...
 

Constructor & Destructor Documentation

◆ NvTrackerMultiThreadWorker() [1/2]

template<typename T >
NvTrackerMultiThreadWorker< T >::NvTrackerMultiThreadWorker ( )

Initialize an empty worker queue.

◆ ~NvTrackerMultiThreadWorker() [1/2]

template<typename T >
NvTrackerMultiThreadWorker< T >::~NvTrackerMultiThreadWorker ( )

Stop and join all persistent worker threads.

◆ NvTrackerMultiThreadWorker() [2/2]

template<typename T >
NvTrackerMultiThreadWorker< T >::NvTrackerMultiThreadWorker ( )

Initialize an empty worker queue.

◆ ~NvTrackerMultiThreadWorker() [2/2]

template<typename T >
NvTrackerMultiThreadWorker< T >::~NvTrackerMultiThreadWorker ( )

Stop and join all persistent worker threads.

Member Function Documentation

◆ initialize() [1/2]

template<typename T >
void NvTrackerMultiThreadWorker< T >::initialize ( const uint  numThreads,
std::function< void(T)>  funcPerThread 
)

Launch all worker threads and worker function.

Parameters
[in]numThreadsNumber of worker threads.
[in]funcPerThreadFunction to execute in each thread.

◆ initialize() [2/2]

template<typename T >
void NvTrackerMultiThreadWorker< T >::initialize ( const uint  numThreads,
std::function< void(T)>  funcPerThread 
)

Launch all worker threads and worker function.

Parameters
[in]numThreadsNumber of worker threads.
[in]funcPerThreadFunction to execute in each thread.

◆ isInitialized() [1/2]

template<typename T >
bool NvTrackerMultiThreadWorker< T >::isInitialized ( )
inline

◆ isInitialized() [2/2]

template<typename T >
bool NvTrackerMultiThreadWorker< T >::isInitialized ( )
inline

◆ submitInput() [1/2]

template<typename T >
void NvTrackerMultiThreadWorker< T >::submitInput ( T  inData)

Submit association input data to queue in main thread.

Parameters
[in]inDataJob data queued for a worker thread.

◆ submitInput() [2/2]

template<typename T >
void NvTrackerMultiThreadWorker< T >::submitInput ( T  inData)

Submit association input data to queue in main thread.

Parameters
[in]inDataJob data queued for a worker thread.

◆ threadLoopFunc() [1/2]

template<typename T >
void NvTrackerMultiThreadWorker< T >::threadLoopFunc ( )

Process queued jobs until the worker receives a deinitialization signal.

◆ threadLoopFunc() [2/2]

template<typename T >
void NvTrackerMultiThreadWorker< T >::threadLoopFunc ( )

Process queued jobs until the worker receives a deinitialization signal.

◆ waitToFinish() [1/2]

template<typename T >
void NvTrackerMultiThreadWorker< T >::waitToFinish ( )

Wait all worker threads to finish in main thread.

◆ waitToFinish() [2/2]

template<typename T >
void NvTrackerMultiThreadWorker< T >::waitToFinish ( )

Wait all worker threads to finish in main thread.

Field Documentation

◆ m_cond4In

template<typename T >
std::condition_variable NvTrackerMultiThreadWorker< T >::m_cond4In

Condition variable associated with the input queue.

Definition at line 351 of file sources/libs/nvmultiobjecttracker/include/modules/NvMultiObjectTracker/NvMultiObjectTracker_common.hpp.

◆ m_cond4Out

template<typename T >
std::condition_variable NvTrackerMultiThreadWorker< T >::m_cond4Out

Condition variable associated with the output.

Definition at line 352 of file sources/libs/nvmultiobjecttracker/include/modules/NvMultiObjectTracker/NvMultiObjectTracker_common.hpp.

◆ m_finishedJobCnt

template<typename T >
uint NvTrackerMultiThreadWorker< T >::m_finishedJobCnt

Keep track of how many tasks are finished.

Definition at line 357 of file sources/libs/nvmultiobjecttracker/include/modules/NvMultiObjectTracker/NvMultiObjectTracker_common.hpp.

◆ m_funcPerThread

template<typename T >
std::function< void(T)> NvTrackerMultiThreadWorker< T >::m_funcPerThread

Data processing function in each worker thread.

Definition at line 358 of file sources/libs/nvmultiobjecttracker/include/modules/NvMultiObjectTracker/NvMultiObjectTracker_common.hpp.

◆ m_inputLock

template<typename T >
std::mutex NvTrackerMultiThreadWorker< T >::m_inputLock

◆ m_inputQueue

template<typename T >
std::queue< T > NvTrackerMultiThreadWorker< T >::m_inputQueue

◆ m_isInit

template<typename T >
bool NvTrackerMultiThreadWorker< T >::m_isInit

◆ m_outputLock

template<typename T >
std::mutex NvTrackerMultiThreadWorker< T >::m_outputLock

◆ m_persistThreadRunning

template<typename T >
bool NvTrackerMultiThreadWorker< T >::m_persistThreadRunning

Whether associate persistent threads should keep running; set false if receive deinit signal.

Definition at line 355 of file sources/libs/nvmultiobjecttracker/include/modules/NvMultiObjectTracker/NvMultiObjectTracker_common.hpp.

◆ m_submittedJobCnt

template<typename T >
uint NvTrackerMultiThreadWorker< T >::m_submittedJobCnt

Keep track of how many tasks are submitted.

Definition at line 356 of file sources/libs/nvmultiobjecttracker/include/modules/NvMultiObjectTracker/NvMultiObjectTracker_common.hpp.

◆ m_threadList

template<typename T >
std::vector< std::thread > NvTrackerMultiThreadWorker< T >::m_threadList

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