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