MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / read

Method read

Libraries/Async/Async.cpp:748–771  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

746}
747
748SC::Result SC::AsyncFileSystemOperation::read(AsyncEventLoop& eventLoop, FileDescriptor::Handle handle,
749 Span<char> buffer, uint64_t offset)
750{
751 SC_TRY(checkState());
752 operation = Operation::Read;
753 new (&readData, PlacementNew()) ReadData({handle, buffer, offset});
754 if (not eventLoop.needsThreadPoolForFileOperations() and threadPoolMode != AsyncThreadPoolMode::ForceThreadPool)
755 {
756 return eventLoop.start(*this);
757 }
758
759 loopWork.work = [&]()
760 {
761 FileDescriptor fd(readData.handle);
762 Span<char> actuallyRead;
763 SC::Result readResult = fd.read(readData.buffer, actuallyRead, readData.offset);
764 fd.detach();
765 SC_TRY(readResult);
766 completionData.numBytes = actuallyRead.sizeInBytes();
767 return SC::Result(true);
768 };
769 loopWork.callback.bind<AsyncFileSystemOperation, &AsyncFileSystemOperation::onOperationCompleted>(*this);
770 return eventLoop.start(loopWork);
771}
772
773SC::Result SC::AsyncFileSystemOperation::write(AsyncEventLoop& eventLoop, FileDescriptor::Handle handle,
774 Span<const char> buffer, uint64_t offset)

Callers 1

await_suspendMethod · 0.45

Calls 6

PlacementNewClass · 0.85
ResultClass · 0.70
startMethod · 0.45
detachMethod · 0.45
sizeInBytesMethod · 0.45

Tested by

no test coverage detected