MCPcopy Create free account
hub / github.com/3rdparty/libprocess / send

Method send

src/socket.cpp:196–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194
195
196Future<Nothing> SocketImpl::send(const string& data)
197{
198 // Extend lifetime by holding onto a reference to ourself!
199 auto self = shared_from_this();
200
201 // We need to share the `index` between both lambdas below.
202 std::shared_ptr<size_t> index(new size_t(0));
203
204 // We store `data.size()` so that we won't make a copy of `data` in
205 // each lambda below since some `data` might be very big!
206 const size_t size = data.size();
207
208 return loop(
209 None(),
210 [=]() {
211 return self->send(data.data() + *index, size - *index);
212 },
213 [=](size_t length) -> ControlFlow<Nothing> {
214 if ((*index += length) != size) {
215 return Continue();
216 }
217 return Break();
218 });
219}
220
221} // namespace internal {
222} // namespace network {

Callers

nothing calls this directly

Calls 4

loopFunction · 0.85
ContinueClass · 0.50
BreakFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected