7 #ifndef PACKAGER_FILE_THREADED_IO_FILE_H_
8 #define PACKAGER_FILE_THREADED_IO_FILE_H_
13 #include <absl/synchronization/mutex.h>
15 #include <packager/file.h>
16 #include <packager/file/file_closer.h>
17 #include <packager/file/io_cache.h>
18 #include <packager/macros/classes.h>
25 enum Mode { kInputMode, kOutputMode };
29 uint64_t io_cache_size,
30 uint64_t io_block_size);
34 bool Close()
override;
35 int64_t Read(
void* buffer, uint64_t length)
override;
36 int64_t Write(
const void* buffer, uint64_t length)
override;
37 void CloseForWriting()
override;
38 int64_t Size()
override;
39 bool Flush()
override;
40 bool Seek(uint64_t position)
override;
41 bool Tell(uint64_t* position)
override;
53 void RunInInputMode();
54 void RunInOutputMode();
55 void WaitForSignal(absl::Mutex* mutex,
bool* condition);
57 std::unique_ptr<File, FileCloser> internal_file_;
60 std::vector<uint8_t> io_buffer_;
63 std::atomic<bool> eof_;
64 std::atomic<int64_t> internal_file_error_;
66 absl::Mutex flush_mutex_;
67 bool flushing_ ABSL_GUARDED_BY(flush_mutex_);
68 bool flush_complete_ ABSL_GUARDED_BY(flush_mutex_);
70 absl::Mutex task_exited_mutex_;
71 bool task_exited_ ABSL_GUARDED_BY(task_exited_mutex_);
Declaration of class which implements a thread-safe circular buffer.
Declaration of class which implements a thread-safe circular buffer.
All the methods that are virtual are virtual for mocking.