pipeConnection.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef EQNET_PIPE_CONNECTION_H
00019 #define EQNET_PIPE_CONNECTION_H
00020
00021 #ifdef WIN32
00022 # include <eq/net/connection.h>
00023 #else
00024 # include "fdConnection.h"
00025 #endif
00026
00027 #include <eq/base/thread.h>
00028
00029 namespace eq
00030 {
00031 namespace net
00032 {
00040 class PipeConnection
00041 #ifdef WIN32
00042 : public Connection
00043 #else
00044 : public FDConnection
00045 #endif
00046 {
00047 public:
00049 EQ_EXPORT PipeConnection();
00051 EQ_EXPORT virtual ~PipeConnection();
00052
00053 virtual bool connect();
00054 virtual void close();
00055
00056 #ifdef WIN32
00057 virtual Notifier getNotifier() const { return _dataPending; }
00058 bool hasData() const
00059 { return WaitForSingleObject( _dataPending, 0 ) == WAIT_OBJECT_0; }
00060 #endif
00061
00062 protected:
00063 #ifdef WIN32
00064 virtual void readNB( void* buffer, const uint64_t bytes );
00065 virtual int64_t readSync( void* buffer, const uint64_t bytes );
00066 virtual int64_t write( const void* buffer, const uint64_t bytes );
00067 #endif
00068
00069 private:
00070 bool _createPipe();
00071
00072 #ifdef WIN32
00073 HANDLE _readHandle;
00074 HANDLE _writeHandle;
00075 mutable base::Lock _mutex;
00076 mutable uint64_t _size;
00077 mutable HANDLE _dataPending;
00078 #endif
00079 };
00080 }
00081 }
00082
00083 #endif //EQNET_PIPE_CONNECTION_H