00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _SUPPORT_PIPE_H
00014 #define _SUPPORT_PIPE_H
00015
00021 #include <support/ByteStream.h>
00022 #include <support/Locker.h>
00023 #include <support/ConditionVariable.h>
00024
00025 #if _SUPPORTS_NAMESPACE
00026 namespace palmos {
00027 namespace support {
00028 #endif
00029
00034
00035 class BPipe : public BnByteInput, public BnByteOutput
00036 {
00037 BPipe (const BPipe &);
00038 BPipe &operator= (const BPipe &);
00039
00040 size_t mSize;
00041 void *mBuffer;
00042
00043 size_t mReadOffset,mWriteOffset;
00044 volatile int32_t mSpaceAvailable;
00045
00046 volatile bool mPipeHalfClosed;
00047
00048 SLocker mReadSerializer,mWriteSerializer;
00049 SConditionVariable mSpaceAvailableCV,mDataAvailableCV;
00050
00051 protected:
00052 virtual ~BPipe();
00053
00054 ssize_t PrvWrite (const void *data, size_t size, uint32_t flags);
00055 status_t PrvWriteEOS();
00056
00057 ssize_t PrvRead (void *data, size_t size, uint32_t flags);
00058
00059 public:
00060
00061 BPipe (size_t size);
00062
00063 virtual ssize_t ReadV (const struct iovec *vector,
00064 ssize_t count,
00065 uint32_t flags = 0);
00066
00067 virtual ssize_t WriteV (const struct iovec *vector,
00068 ssize_t count,
00069 uint32_t flags = 0);
00070
00071 virtual status_t Sync();
00072
00073 virtual SValue Inspect (const sptr<IBinder>& caller,
00074 const SValue &which,
00075 uint32_t flags = 0);
00076 };
00077
00080 #if _SUPPORTS_NAMESPACE
00081 } }
00082 #endif
00083
00084 #endif // _SUPPORT_PIPE_H