void sender() { int n = 0; while (n < 100) { buf.send(n); std::cout << "sent: " << n << std::endl; ++n; } buf.send(-1); }
void sender() { int n = 0; while (n < 100) { buf.send(n); { boost::mutex::scoped_lock io_lock(io_mutex); std::cout << "sent: " << n << std::endl; } ++n; } buf.send(-1); }
void sender() { int n = 0; while (n < 1000000) { buf.send(n); if(!(n%10000)) { boost::unique_lock<boost::mutex> io_lock(io_mutex); std::cout << "sent: " << n << std::endl; } ++n; } buf.send(-1); }
void receiver() { int n; do { n = buf.receive(); if(!(n%10000)) { boost::unique_lock<boost::mutex> io_lock(io_mutex); std::cout << "received: " << n << std::endl; } } while (n != -1); // -1 indicates end of buffer buf.send(-1); }