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

Method write

Libraries/Async/Async.cpp:773–795  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

771}
772
773SC::Result SC::AsyncFileSystemOperation::close(AsyncEventLoop& eventLoop, FileDescriptor::Handle handle)
774{
775 SC_TRY(checkState());
776 operation = Operation::Close;
777 new (&closeData, PlacementNew()) CloseData({handle});
778 if (not eventLoop.needsThreadPoolForFileOperations() and threadPoolMode != AsyncThreadPoolMode::ForceThreadPool)
779 {
780 return eventLoop.start(*this);
781 }
782
783 loopWork.work = [&]()
784 {
785 FileDescriptor fd(closeData.handle);
786 return fd.close();
787 };
788 loopWork.callback.bind<AsyncFileSystemOperation, &AsyncFileSystemOperation::onOperationCompleted>(*this);
789 return eventLoop.start(loopWork);
790}
791
792SC::Result SC::AsyncFileSystemOperation::read(AsyncEventLoop& eventLoop, FileDescriptor::Handle handle,
793 Span<char> buffer, uint64_t offset)
794{
795 SC_TRY(checkState());
796 operation = Operation::Read;
797 new (&readData, PlacementNew()) ReadData({handle, buffer, offset});
798 if (not eventLoop.needsThreadPoolForFileOperations() and threadPoolMode != AsyncThreadPoolMode::ForceThreadPool)

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