Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #ifndef LIBRARIES_NACL_IO_FIFO_CHAR_H_ | |
| 6 #define LIBRARIES_NACL_IO_FIFO_CHAR_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 #include <stdlib.h> | |
| 10 | |
| 11 namespace nacl_io { | |
| 12 | |
| 13 class FIFOChar { | |
|
binji
2013/09/12 01:47:57
nit: remove extra space
noelallen1
2013/09/12 23:19:03
Done.
| |
| 14 public: | |
| 15 explicit FIFOChar(size_t size); | |
| 16 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
| |
| 17 | |
| 18 virtual bool IsEmpty(); | |
| 19 virtual bool IsFull(); | |
| 20 virtual bool Resize(size_t len); | |
| 21 | |
| 22 size_t ReadAvailable(); | |
| 23 size_t WriteAvailable(); | |
| 24 | |
| 25 // Reads out no more than the requested len without updating the tail. | |
| 26 // Returns actual amount read. | |
| 27 size_t Peek(char* buf, size_t len); | |
| 28 | |
| 29 // Reads out the data making room in the FIFO. Returns actual amount | |
| 30 // read. | |
| 31 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.
| |
| 32 | |
| 33 // Writes into the FIFO no more than len bytes, returns actual amount | |
| 34 // written. | |
| 35 size_t Write(const char* buf, size_t len); | |
| 36 | |
| 37 | |
| 38 private: | |
| 39 char* buffer_; | |
| 40 size_t size_; // Size of the FIFO | |
| 41 size_t avail_; // How much data is currently available | |
| 42 size_t tail_; // Next read location | |
|
binji
2013/09/12 01:47:57
I usually think of the head being the start of the
| |
| 43 }; | |
| 44 | |
| 45 } // namespace nacl_io | |
| 46 | |
| 47 #endif // LIBRARIES_NACL_IO_FIFO_CHAR_H_ | |
| OLD | NEW |