| 746 | } |
| 747 | |
| 748 | SC::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 | |
| 773 | SC::Result SC::AsyncFileSystemOperation::write(AsyncEventLoop& eventLoop, FileDescriptor::Handle handle, |
| 774 | Span<const char> buffer, uint64_t offset) |
no test coverage detected