| 63 | } |
| 64 | |
| 65 | void TCPConnectionImpl::lockFreeDoSend() { |
| 66 | if (_pendingPackets.empty()) { |
| 67 | return; |
| 68 | } |
| 69 | |
| 70 | auto bytes = _pendingPackets.front(); |
| 71 | |
| 72 | boost::asio::async_write(_socket, |
| 73 | boost::asio::buffer(bytes.data(), bytes.size()), |
| 74 | [strongSelf = strongSmallRef(this)](boost::system::error_code ec, std::size_t /*length*/) { |
| 75 | if (ec.failed()) { |
| 76 | strongSelf->close(errorFromBoostError(ec)); |
| 77 | return; |
| 78 | } |
| 79 | |
| 80 | std::lock_guard<Mutex> guard(strongSelf->_mutex); |
| 81 | if (strongSelf->_closed) { |
| 82 | return; |
| 83 | } |
| 84 | strongSelf->_pendingPackets.pop_front(); |
| 85 | strongSelf->lockFreeDoSend(); |
| 86 | }); |
| 87 | } |
| 88 | |
| 89 | void TCPConnectionImpl::close(const Error& error) { |
| 90 | Shared<ITCPConnectionDisconnectListener> listener; |
no test coverage detected