Template Class ThreadsafeBatchingPool¶
Defined in File threadsafe_batching_pool.h
Class Documentation¶
-
template<class
BatchingPoolType
>
classThreadsafeBatchingPool
¶ The following mechanism operates in a multithreaded async-workflow guarding access to the pushes to the structure keeping sentences bucketed by length and sorted by priority.
This is a wrap of a producer-consumer queue implemented as a monitor, where there is a mutex guarding the underlying data structure (BatchingPoolType) and (worker/consumer) threads waiting on a condition variable and the queuing thread producing and notifying waiting threads (consumers) through the same condition variable.
Originally written by for a single model (where items are produce: Request, consume: Batch), converted to also work for multiple models where items are produce: (TranslationModel, Request), consume: (TranlsationModel, Batch). This is accomplished by template parameter packs.
Requires BatchingPoolType to implement the following:
produce:
size_t enqueueRequest(...)
(returns number elements produced)consume:
size_t generateBatch(...)
(returns number of elements available to be consumed)