Multiple producers / multiple consumers wait batcher example
#include <iostream>
#include <iterator>
#include <string>
#include <thread>
int main(int argc, char** argv)
{
std::cout << "Please enter some string. Enter the empty string to exit..." << std::endl;
auto consumer = std::thread([&batcher]()
{
std::vector<char> items;
{
std::cout << "Your entered: ";
std::copy(items.begin(), items.end(), std::ostream_iterator<char>(std::cout, ""));
std::cout << std::endl;
}
});
std::string line;
while (getline(std::cin, line))
{
if (!batcher.
Enqueue(line.begin(), line.end()))
break;
if (line.empty())
{
break;
}
}
consumer.join();
return 0;
}
Multiple producers / multiple consumers wait batcher.
void Close()
Close the wait batcher.
bool Dequeue(std::vector< T > &items)
Dequeue all items from the wait batcher.
bool Enqueue(const T &item)
Enqueue an item into the wait batcher.
Multiple producers / multiple consumers wait batcher definition.