MCPcopy Create free account
hub / github.com/apache/mesos / write_internal

Function write_internal

3rdparty/libprocess/src/windows/libwinio.cpp:496–529  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

494
495
496static Future<size_t> write_internal(
497 const int_fd& fd, const void* buf, size_t size, IOType type)
498{
499 process::initialize();
500
501 Promise<size_t>* promise = new Promise<size_t>();
502 Future<size_t> future = promise->future();
503
504 // We use a `std::shared_ptr`, so we can safely support canceling.
505 auto overlapped = std::make_shared<IOOverlappedReadWrite>(
506 IOOverlappedBase{OVERLAPPED{}, fd, type}, promise);
507
508 enable_cancellation(fd, future, overlapped);
509
510 // Start the asynchronous operation.
511 const Result<size_t> result =
512 os::write_async(fd, buf, size, &overlapped->base.overlapped);
513
514 // If the request is pending, then we return immediately and have the
515 // callback free the promise and overlapped.
516 if (result.isNone()) {
517 return future;
518 }
519
520 // In an error or immediate success, we have to manually set the promise
521 // and free it.
522 if (result.isError()) {
523 promise->fail("os::write_async failed: " + result.error());
524 } else if (result.isSome()) {
525 promise->set(result.get());
526 }
527 delete promise;
528 return future;
529}
530
531
532Future<size_t> read(const int_fd& fd, void* buf, size_t size)

Callers 2

writeFunction · 0.85
sendFunction · 0.85

Calls 11

enable_cancellationFunction · 0.85
write_asyncFunction · 0.85
errorMethod · 0.65
initializeFunction · 0.50
futureMethod · 0.45
isNoneMethod · 0.45
isErrorMethod · 0.45
failMethod · 0.45
isSomeMethod · 0.45
setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected