1 /**\r
2 * Copyright (C) ARM Limited 2010-2012. All rights reserved.\r
3 *\r
4 * This program is free software; you can redistribute it and/or modify\r
5 * it under the terms of the GNU General Public License version 2 as\r
6 * published by the Free Software Foundation.\r
7 */\r
8 \r
9 #ifndef __FIFO_H__\r
10 #define __FIFO_H__\r
11 \r
12 #include <semaphore.h>\r
13 \r
14 class Fifo {\r
15 public:\r
16 Fifo(int singleBufferSize, int totalBufferSize);\r
17 ~Fifo();\r
18 int numBytesFilled();\r
19 bool isEmpty();\r
20 bool isFull();\r
21 bool willFill(int additional);\r
22 char* start();\r
23 char* write(int length);\r
24 char* read(int* length);\r
25 \r
26 private:\r
27 int mSingleBufferSize, mWrite, mRead, mReadCommit, mRaggedEnd, mWrapThreshold;\r
28 sem_t mWaitForSpaceSem, mWaitForDataSem;\r
29 char* mBuffer;\r
30 bool mEnd;\r
31 };\r
32 \r
33 #endif //__FIFO_H__\r