00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __CNAMEDPIPECOMM_H__
00022 #define __CNAMEDPIPECOMM_H__
00023
00024
00025 #include <stdio.h>
00026
00027 #ifdef _MSC_VER
00028 #pragma warning(disable:4786)
00029 #endif
00030
00031 #include <deque>
00032
00033 #include "util.h"
00034 #include "opp_string.h"
00035 #include "cparsimcomm.h"
00036
00037
00038
00039 #if defined(_WIN32)
00040 #define USE_WINDOWS_PIPES
00041 #endif
00042
00043
00044 #ifdef USE_WINDOWS_PIPES
00045 #define MEAN_AND_LEAN
00046 #include <windows.h>
00047 typedef HANDLE PIPE;
00048 #else
00049 typedef int PIPE;
00050 #endif
00051
00052
00060 class cNamedPipeCommunications : public cParsimCommunications
00061 {
00062 protected:
00063 int numPartitions;
00064 int myProcId;
00065
00066
00067 opp_string prefix;
00068 PIPE *rpipes;
00069 PIPE *wpipes;
00070 int maxFdPlus1;
00071 int rrBase;
00072
00073
00074 std::deque<cCommBuffer*> storedBuffers;
00075
00076 protected:
00077
00078 bool receive(int filtTag, cCommBuffer *buffer, int& receivedTag, int& sourceProcId, bool blocking);
00079 bool doReceive(cCommBuffer *buffer, int& receivedTag, int& sourceProcId, bool blocking);
00080
00081 public:
00085 cNamedPipeCommunications();
00086
00090 virtual ~cNamedPipeCommunications();
00091
00097 virtual void init();
00098
00102 virtual void shutdown();
00103
00107 virtual int getNumPartitions();
00108
00112 virtual int getProcId();
00113
00117 virtual cCommBuffer *createCommBuffer();
00118
00122 virtual void recycleCommBuffer(cCommBuffer *buffer);
00123
00127 virtual void send(cCommBuffer *buffer, int tag, int destination);
00128
00133 virtual bool receiveBlocking(int filtTag, cCommBuffer *buffer, int& receivedTag, int& sourceProcId);
00134
00140 virtual bool receiveNonblocking(int filtTag, cCommBuffer *buffer, int& receivedTag, int& sourceProcId);
00142 };
00143
00144 #endif
00145
00146