Chromium Code Reviews| Index: native_client_sdk/src/libraries/nacl_io/fifo_char.h |
| diff --git a/native_client_sdk/src/libraries/nacl_io/fifo_char.h b/native_client_sdk/src/libraries/nacl_io/fifo_char.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f6aa182b49f817aee181fcc2f747a856085fe58a |
| --- /dev/null |
| +++ b/native_client_sdk/src/libraries/nacl_io/fifo_char.h |
| @@ -0,0 +1,47 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef LIBRARIES_NACL_IO_FIFO_CHAR_H_ |
| +#define LIBRARIES_NACL_IO_FIFO_CHAR_H_ |
| + |
| +#include <stdint.h> |
| +#include <stdlib.h> |
| + |
| +namespace nacl_io { |
| + |
| +class FIFOChar { |
|
binji
2013/09/12 01:47:57
nit: remove extra space
noelallen1
2013/09/12 23:19:03
Done.
|
| + public: |
| + explicit FIFOChar(size_t size); |
| + virtual ~FIFOChar(); |
|
binji
2013/09/12 01:47:57
why virtual? here and elsewhere.
noelallen1
2013/09/12 23:19:03
The base 'interface' class has a virtual destructo
|
| + |
| + virtual bool IsEmpty(); |
| + virtual bool IsFull(); |
| + virtual bool Resize(size_t len); |
| + |
| + size_t ReadAvailable(); |
| + size_t WriteAvailable(); |
| + |
| + // Reads out no more than the requested len without updating the tail. |
| + // Returns actual amount read. |
| + size_t Peek(char* buf, size_t len); |
| + |
| + // Reads out the data making room in the FIFO. Returns actual amount |
| + // read. |
| + size_t Read(char* buf, size_t len); |
|
binji
2013/09/12 01:47:57
match MountNode::Read/Write?
Read(void* buf, size
noelallen1
2013/09/12 23:19:03
Done.
|
| + |
| + // Writes into the FIFO no more than len bytes, returns actual amount |
| + // written. |
| + size_t Write(const char* buf, size_t len); |
| + |
| + |
| +private: |
| + char* buffer_; |
| + size_t size_; // Size of the FIFO |
| + size_t avail_; // How much data is currently available |
| + size_t tail_; // Next read location |
|
binji
2013/09/12 01:47:57
I usually think of the head being the start of the
|
| +}; |
| + |
| +} // namespace nacl_io |
| + |
| +#endif // LIBRARIES_NACL_IO_FIFO_CHAR_H_ |