Shaka Packager SDK
Public Member Functions | List of all members
shaka::IoCache Class Reference

Declaration of class which implements a thread-safe circular buffer. More...

#include <io_cache.h>

Public Member Functions

 IoCache (uint64_t cache_size)
 
uint64_t Read (void *buffer, uint64_t size)
 
uint64_t Write (const void *buffer, uint64_t size)
 
void Clear ()
 Empties the cache.
 
void Close ()
 
bool closed ()
 
void Reopen ()
 Reopens the cache. Any data still in the cache will be lost.
 
uint64_t BytesCached ()
 
uint64_t BytesFree ()
 
void WaitUntilEmptyOrClosed ()
 Waits until the cache is empty or has been closed.
 

Detailed Description

Declaration of class which implements a thread-safe circular buffer.

Definition at line 20 of file io_cache.h.

Member Function Documentation

◆ BytesCached()

uint64_t shaka::IoCache::BytesCached ( )

Returns the number of bytes in the cache.

Returns
the number of bytes in the cache.

Definition at line 119 of file io_cache.cc.

◆ BytesFree()

uint64_t shaka::IoCache::BytesFree ( )

Returns the number of free bytes in the cache.

Returns
the number of free bytes in the cache.

Definition at line 124 of file io_cache.cc.

◆ Close()

void shaka::IoCache::Close ( )

Close the cache. This will call any blocking calls to unblock, and the cache won't be usable until Reopened.

Definition at line 105 of file io_cache.cc.

◆ closed()

bool shaka::IoCache::closed ( )
inline
Returns
true if the cache is closed, false otherwise.

Definition at line 50 of file io_cache.h.

◆ Read()

uint64_t shaka::IoCache::Read ( void *  buffer,
uint64_t  size 
)

Read data from the cache. This function may block until there is data in the cache.

Parameters
bufferis a buffer into which to read the data from the cache.
sizeis the size of buffer.
Returns
the number of bytes read into buffer, or 0 if the call unblocked because the cache has been closed and is empty.

Definition at line 33 of file io_cache.cc.

◆ Write()

uint64_t shaka::IoCache::Write ( const void *  buffer,
uint64_t  size 
)

Write data to the cache. This function may block until there is enough room in the cache.

Parameters
bufferis a buffer containing the data to be written to the cache.
sizeis the size of the data to be written to the cache.
Returns
the amount of data written to the buffer (which will equal data), or 0 if the call unblocked because the cache has been closed.

Definition at line 60 of file io_cache.cc.


The documentation for this class was generated from the following files: