SpillBuffer.h 544 B

1234567891011121314151617181920212223
  1. #pragma once
  2. class SpillBuffer
  3. {
  4. public:
  5. SpillBuffer();
  6. ~SpillBuffer();
  7. bool reserve(size_t bytes);
  8. void clear();
  9. void reset();
  10. size_t write(const void *src, size_t len);
  11. bool get(void **buffer, size_t *len);
  12. bool full() const;
  13. bool empty() const;
  14. void remove(size_t len); // removes len bytes from the start of the spill buffer
  15. size_t remaining() const; // how many bytes to fill it up
  16. size_t length() const; /* buffer length when full */
  17. private:
  18. volatile size_t spillBufferUsed;
  19. size_t spillBufferSize;
  20. char *spillBuffer;
  21. };