00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00048 #ifndef __vtkSharedMemoryCommunicator_h
00049 #define __vtkSharedMemoryCommunicator_h
00050
00051 #include "vtkCommunicator.h"
00052
00053 class vtkThreadedController;
00054 class vtkSharedMemoryCommunicatorMessage;
00055 class vtkSimpleCriticalSection;
00056
00057 class VTK_PARALLEL_EXPORT vtkSharedMemoryCommunicator : public vtkCommunicator
00058 {
00059 public:
00060 vtkTypeRevisionMacro( vtkSharedMemoryCommunicator,vtkCommunicator);
00061
00063 static vtkSharedMemoryCommunicator* New();
00064
00065 virtual void PrintSelf(ostream& os, vtkIndent indent);
00066
00068
00070 virtual int Send(int* data, int length, int remoteThreadId, int tag);
00071 virtual int Send(unsigned long* data, int length, int remoteThreadId,
00072 int tag);
00073 virtual int Send(char* data, int length, int remoteThreadId, int tag);
00074 virtual int Send(unsigned char* data, int length, int remoteThreadId, int tag);
00075 virtual int Send(float* data, int length, int remoteThreadId, int tag);
00076 virtual int Send(double* data, int length, int remoteThreadId, int tag);
00077 #ifdef VTK_USE_64BIT_IDS
00078 virtual int Send(vtkIdType* data, int length, int remoteThreadId, int tag);
00080 #endif
00081 virtual int Send(vtkDataObject* data, int remoteThreadId, int tag);
00082 virtual int Send(vtkDataArray* data, int remoteThreadId, int tag);
00083
00085
00088 virtual int Receive(int* data, int length, int remoteThreadId,
00089 int tag);
00090 virtual int Receive(unsigned long* data, int length,
00091 int remoteThreadId, int tag);
00092 virtual int Receive(char* data, int length, int remoteThreadId,
00093 int tag);
00094 virtual int Receive(unsigned char* data, int length, int remoteThreadId,
00095 int tag);
00096 virtual int Receive(float* data, int length, int remoteThreadId,
00097 int tag);
00098 virtual int Receive(double* data, int length, int remoteThreadId,
00099 int tag);
00100 #ifdef VTK_USE_64BIT_IDS
00101 virtual int Receive(vtkIdType* data, int length, int remoteThreadId,
00102 int tag);
00104 #endif
00105 virtual int Receive(vtkDataObject *data, int remoteThreadId, int tag);
00106 virtual int Receive(vtkDataArray *data, int remoteThreadId, int tag);
00107
00108
00109
00110 friend class vtkThreadedController;
00111
00112
00113
00114 protected:
00115
00116 int NumberOfThreads;
00117 int Initialized;
00118 void Initialize(int nThreads, int forceDeepCopy);
00119
00120 int LocalThreadId;
00121 int WaitingForId;
00122
00123 int ForceDeepCopy;
00124
00125
00126
00127
00128 vtkSimpleCriticalSection* MessageListLock;
00129
00130
00131
00132 vtkSharedMemoryCommunicator** Communicators;
00133
00134 vtkSharedMemoryCommunicator* Parent;
00135
00136
00137 vtkSharedMemoryCommunicatorMessage *MessageListStart;
00138 vtkSharedMemoryCommunicatorMessage *MessageListEnd;
00139
00140 vtkSharedMemoryCommunicator();
00141 ~vtkSharedMemoryCommunicator();
00142
00143
00144 int Send(vtkDataObject* object, void *data, int dataLength,
00145 int remoteThreadId, int tag);
00146 int Receive(vtkDataObject* object, void *data, int dataLength,
00147 int remoteThreadId, int tag);
00148
00149 int Send(vtkDataArray* object, int dataLength,
00150 int remoteThreadId, int tag);
00151 int Receive(vtkDataArray* object, int dataLength,
00152 int remoteThreadId, int tag);
00153
00154 vtkSharedMemoryCommunicatorMessage* NewMessage(vtkDataObject* object,
00155 void* data,
00156 int dataLength);
00157 vtkSharedMemoryCommunicatorMessage* NewMessage(vtkDataArray* object,
00158 void* data,
00159 int dataLength);
00160 void DeleteMessage(vtkSharedMemoryCommunicatorMessage *message);
00161 void AddMessage(vtkSharedMemoryCommunicatorMessage *message);
00162 vtkSharedMemoryCommunicatorMessage* FindMessage(int sendId, int tag);
00163
00164 #ifdef _WIN32
00165
00166
00167 HANDLE MessageSignal;
00168 #else
00169
00170
00171 vtkSimpleCriticalSection* Gate;
00172 #endif
00173
00174 void SignalNewMessage(vtkSharedMemoryCommunicator* receiveCommunicator);
00175
00176 void WaitForNewMessage();
00177
00178 private:
00179 vtkSharedMemoryCommunicator(const vtkSharedMemoryCommunicator&);
00180 void operator=(const vtkSharedMemoryCommunicator&);
00181 };
00182
00183 #endif // __vtkSharedMemoryCommunicator_h