| 56 | } |
| 57 | |
| 58 | bool producePoint(pdal::PointRef& p) |
| 59 | { |
| 60 | { |
| 61 | // Waiting for the consumer to be ready and to have consumed the |
| 62 | // previous point |
| 63 | std::unique_lock<std::mutex> l(mutex); |
| 64 | cv.wait(l, []{ return ready; }); |
| 65 | cv.wait(l, []{ return !produced; }); |
| 66 | |
| 67 | x = p.getFieldAs<double>(pdal::Dimension::Id::X); |
| 68 | y = p.getFieldAs<double>(pdal::Dimension::Id::Y); |
| 69 | z = p.getFieldAs<double>(pdal::Dimension::Id::Z); |
| 70 | |
| 71 | produced = true; |
| 72 | } |
| 73 | |
| 74 | // Unlock before notifying, to avoid waking up the waiting thread only to |
| 75 | // block again (see notify_one for details) |
| 76 | cv.notify_one(); |
| 77 | |
| 78 | return true; |
| 79 | } |
| 80 | |
| 81 | void makeProducer(const std::string& filename) |
| 82 | { |