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