7 #ifndef PACKAGER_FILE_IO_CACHE_H_
8 #define PACKAGER_FILE_IO_CACHE_H_
12 #include "packager/base/macros.h"
13 #include "packager/base/synchronization/lock.h"
14 #include "packager/base/synchronization/waitable_event.h"
21 explicit IoCache(uint64_t cache_size);
30 uint64_t
Read(
void* buffer, uint64_t size);
39 uint64_t
Write(
const void* buffer, uint64_t size);
66 uint64_t BytesCachedInternal();
67 uint64_t BytesFreeInternal();
69 const uint64_t cache_size_;
71 base::WaitableEvent read_event_;
72 base::WaitableEvent write_event_;
73 std::vector<uint8_t> circular_buffer_;
74 const uint8_t* end_ptr_;
79 DISALLOW_COPY_AND_ASSIGN(
IoCache);
Declaration of class which implements a thread-safe circular buffer.
void Clear()
Empties the cache.
uint64_t Write(const void *buffer, uint64_t size)
uint64_t Read(void *buffer, uint64_t size)
void WaitUntilEmptyOrClosed()
Waits until the cache is empty or has been closed.
void Reopen()
Reopens the cache. Any data still in the cache will be lost.
All the methods that are virtual are virtual for mocking.