Thread safe receive
| 173 | |
| 174 | // Thread safe receive |
| 175 | proton::message receive() { |
| 176 | std::unique_lock<std::mutex> l(lock_); |
| 177 | // Wait for buffered messages |
| 178 | while (!closed_ && (!work_queue_ || buffer_.empty())) { |
| 179 | can_receive_.wait(l); |
| 180 | } |
| 181 | if (closed_) throw closed("receiver closed"); |
| 182 | proton::message m = std::move(buffer_.front()); |
| 183 | buffer_.pop(); |
| 184 | // Add a lambda to the work queue to call receive_done(). |
| 185 | // This will tell the handler to add more credit. |
| 186 | work_queue_->add([=]() { this->receive_done(); }); |
| 187 | return m; |
| 188 | } |
| 189 | |
| 190 | // Thread safe |
| 191 | void close() { |
no test coverage detected