diff options
author | Fathi Boudra <fathi.boudra@linaro.org> | 2013-03-30 17:35:18 +0200 |
---|---|---|
committer | Fathi Boudra <fathi.boudra@linaro.org> | 2013-03-30 17:35:18 +0200 |
commit | 17c2f0dc0ca55e254fcd7829489757568b3225e7 (patch) | |
tree | 25b11e1b39d626151123a16f16f4b4ca38761609 /daemon/Fifo.h |
Imported Upstream version 5.13.0HEADupstream/5.13.0master
Diffstat (limited to 'daemon/Fifo.h')
-rw-r--r-- | daemon/Fifo.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/daemon/Fifo.h b/daemon/Fifo.h new file mode 100644 index 0000000..e2a5d94 --- /dev/null +++ b/daemon/Fifo.h @@ -0,0 +1,33 @@ +/** + * Copyright (C) ARM Limited 2010-2012. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __FIFO_H__ +#define __FIFO_H__ + +#include <semaphore.h> + +class Fifo { +public: + Fifo(int singleBufferSize, int totalBufferSize); + ~Fifo(); + int numBytesFilled() const; + bool isEmpty() const; + bool isFull() const; + bool willFill(int additional) const; + char* start() const; + char* write(int length); + char* read(int *const length); + +private: + int mSingleBufferSize, mWrite, mRead, mReadCommit, mRaggedEnd, mWrapThreshold; + sem_t mWaitForSpaceSem, mWaitForDataSem; + char* mBuffer; + bool mEnd; +}; + +#endif //__FIFO_H__ |