| 43 | } |
| 44 | |
| 45 | void TCPConnectionImpl::submitData(const BytesView& bytes) { |
| 46 | std::lock_guard<Mutex> guard(_mutex); |
| 47 | |
| 48 | if (_closed) { |
| 49 | return; |
| 50 | } |
| 51 | |
| 52 | bool wasEmpty = _pendingPackets.empty(); |
| 53 | _pendingPackets.emplace_back(bytes); |
| 54 | |
| 55 | if (wasEmpty) { |
| 56 | _ioService.post([strongSelf = strongSmallRef(this)]() { |
| 57 | std::lock_guard<Mutex> lock(strongSelf->_mutex); |
| 58 | if (!strongSelf->_closed) { |
| 59 | strongSelf->lockFreeDoSend(); |
| 60 | } |
| 61 | }); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | void TCPConnectionImpl::lockFreeDoSend() { |
| 66 | if (_pendingPackets.empty()) { |
no test coverage detected