TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
|
A simple producer class. More...
#include <parallel.h>
Public Types | |
using | type = T |
Public Member Functions | |
BufferedProducer (uint8_t nthreads, size_t maxQueueSize, Function &&fn) | |
~BufferedProducer () | |
Stops the producers, discarding any items in the queue. More... | |
std::optional< T > | get () |
void | run (Function fn) |
A simple producer class.
You specify a function that will generate data for you somehow, ending when it returns an optional without a value, and this producer will multithread it for you automatically. The function should be thread-safe, and data is not guaranteed to arrive in the same order it was generated in, unless you do it yourself. If you want to stop the consumer threads, destruct the object. If you try destructing the object while get() is still being called, it will result in a runtime error.
using common::BufferedProducer< T >::type = T |
common::BufferedProducer< T >::BufferedProducer | ( | uint8_t | nthreads, |
size_t | maxQueueSize, | ||
Function && | fn | ||
) |
common::BufferedProducer< T >::~BufferedProducer | ( | ) |
Stops the producers, discarding any items in the queue.
std::optional< T > common::BufferedProducer< T >::get | ( | ) |
void common::BufferedProducer< T >::run | ( | Function | fn | ) |