Multiple producers / multiple consumers wait ring 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([&ring]()
{
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 ring.
bool Enqueue(const T &item)
Enqueue an item into the wait ring.
bool Dequeue(T &item)
Dequeue an item from the wait ring.
void Close()
Close the wait ring.
Multiple producers / multiple consumers wait ring definition.