Skip to content

Commit

Permalink
Add comments to the batch streamer
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-alexandrov committed Nov 21, 2023
1 parent a8cfdbd commit af93ea4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions examples/batch-streamer/batch_streamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,20 @@ void makeConsumer()
while (true)
{
{
// Make the consumer ready
// Tell the producer that the consumer is ready
std::lock_guard l(mutex);
ready = true;
}

// Exit the lock first, so the producer can grab the lock and do work
cv.notify_one();

{
// Wait for the point to be produced
std::unique_lock l(mutex);
cv.wait(l, []{ return produced; });

// Consume the point
std::cout << "Consumed point: " << x << ", " << y << ", " << z
<< " (count: " << point_count << ")\n";
produced = false;
Expand All @@ -55,8 +58,8 @@ void makeConsumer()
bool producePoint(pdal::PointRef& p)
{
{
// Waiting for the consumer to be ready and to have consumed previous
// point
// Waiting for the consumer to be ready and to have consumed the
// previous point
std::unique_lock<std::mutex> l(mutex);
cv.wait(l, []{ return ready; });
cv.wait(l, []{ return !produced; });
Expand Down

0 comments on commit af93ea4

Please sign in to comment.