Line data Source code
1 : #pragma once 2 : 3 : #include <memory> 4 : #include <string> 5 : 6 : #include "source/common/buffer/buffer_impl.h" 7 : #include "source/extensions/common/async_files/async_file_context_base.h" 8 : 9 : #include "absl/status/statusor.h" 10 : 11 : namespace Envoy { 12 : namespace Extensions { 13 : namespace Common { 14 : namespace AsyncFiles { 15 : 16 : class AsyncFileManager; 17 : 18 : // The thread pool implementation of an AsyncFileContext - uses the manager thread pool and 19 : // old-school synchronous posix file operations. 20 : class AsyncFileContextThreadPool final : public AsyncFileContextBase { 21 : public: 22 : explicit AsyncFileContextThreadPool(AsyncFileManager& manager, int fd); 23 : 24 : absl::StatusOr<CancelFunction> 25 : stat(std::function<void(absl::StatusOr<struct stat>)> on_complete) override; 26 : absl::StatusOr<CancelFunction> 27 : createHardLink(absl::string_view filename, 28 : std::function<void(absl::Status)> on_complete) override; 29 : absl::Status close(std::function<void(absl::Status)> on_complete) override; 30 : absl::StatusOr<CancelFunction> 31 : read(off_t offset, size_t length, 32 : std::function<void(absl::StatusOr<Buffer::InstancePtr>)> on_complete) override; 33 : absl::StatusOr<CancelFunction> 34 : write(Buffer::Instance& contents, off_t offset, 35 : std::function<void(absl::StatusOr<size_t>)> on_complete) override; 36 : absl::StatusOr<CancelFunction> 37 : duplicate(std::function<void(absl::StatusOr<AsyncFileHandle>)> on_complete) override; 38 : 39 0 : int& fileDescriptor() { return file_descriptor_; } 40 : 41 : ~AsyncFileContextThreadPool() override; 42 : 43 : protected: 44 : absl::StatusOr<CancelFunction> checkFileAndEnqueue(std::shared_ptr<AsyncFileAction> action); 45 : 46 : int file_descriptor_; 47 : }; 48 : 49 : } // namespace AsyncFiles 50 : } // namespace Common 51 : } // namespace Extensions 52 : } // namespace Envoy