1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef LIBRARIES_NACL_IO_FIFO_CHAR_H_
6 #define LIBRARIES_NACL_IO_FIFO_CHAR_H_
10 #include "nacl_io/fifo_interface.h"
12 #include "sdk_util/macros.h"
18 // A FIFOChar is a circular buffer, signalling FULL and EMPTY as appropriate.
19 class FIFOChar
: public FIFOInterface
{
21 explicit FIFOChar(size_t size
);
24 virtual bool IsEmpty();
25 virtual bool IsFull();
26 virtual bool Resize(size_t len
);
28 virtual size_t ReadAvailable();
29 virtual size_t WriteAvailable();
31 // Reads out no more than the requested len without updating the tail.
32 // Returns actual amount read.
33 size_t Peek(void* buf
, size_t len
);
35 // Reads out the data making room in the FIFO. Returns actual amount
37 size_t Read(void* buf
, size_t len
);
39 // Writes into the FIFO no more than len bytes, returns actual amount
41 size_t Write(const void* buf
, size_t len
);
45 size_t size_
; // Size of the FIFO
46 size_t avail_
; // How much data is currently available
47 size_t tail_
; // Next read location
49 DISALLOW_COPY_AND_ASSIGN(FIFOChar
);
52 } // namespace nacl_io
54 #endif // LIBRARIES_NACL_IO_FIFO_CHAR_H_