7 #ifndef PACKAGER_FILE_THREADED_IO_FILE_H_ 8 #define PACKAGER_FILE_THREADED_IO_FILE_H_ 12 #include "packager/base/synchronization/waitable_event.h" 13 #include "packager/file/file.h" 14 #include "packager/file/file_closer.h" 15 #include "packager/file/io_cache.h" 22 enum Mode { kInputMode, kOutputMode };
26 uint64_t io_cache_size,
27 uint64_t io_block_size);
31 bool Close()
override;
32 int64_t
Read(
void* buffer, uint64_t length)
override;
33 int64_t
Write(
const void* buffer, uint64_t length)
override;
34 int64_t
Size()
override;
35 bool Flush()
override;
36 bool Seek(uint64_t position)
override;
37 bool Tell(uint64_t* position)
override;
49 void RunInInputMode();
50 void RunInOutputMode();
52 std::unique_ptr<File, FileCloser> internal_file_;
55 std::vector<uint8_t> io_buffer_;
58 std::atomic<bool> eof_;
60 base::WaitableEvent flush_complete_event_;
61 std::atomic<int32_t> internal_file_error_;
63 base::WaitableEvent task_exit_event_;
70 #endif // PACKAGER_FILE_THREADED_IO_FILE_H Declaration of class which implements a thread-safe circular buffer.
Define an abstract file interface.
int64_t Write(const void *buffer, uint64_t length) override
Declaration of class which implements a thread-safe circular buffer.
All the methods that are virtual are virtual for mocking.
bool Open() override
Internal open. Should not be used directly.
bool Seek(uint64_t position) override
bool Tell(uint64_t *position) override
int64_t Read(void *buffer, uint64_t length) override