00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00061 #ifndef __vtkThreadedController_h
00062 #define __vtkThreadedController_h
00063
00064 #include "vtkObject.h"
00065 #include "vtkMultiProcessController.h"
00066 #include "vtkMultiThreader.h"
00067
00068
00069 class vtkThreadedControllerMessage;
00070
00071
00072 class VTK_EXPORT vtkThreadedController : public vtkMultiProcessController
00073 {
00074 public:
00075 static vtkThreadedController *New();
00076 vtkTypeMacro(vtkThreadedController,vtkMultiProcessController);
00077 void PrintSelf(ostream& os, vtkIndent indent);
00078
00080 void Initialize(int argc, char *arcv[]);
00081
00087 vtkGetMacro(LocalProcessId, int);
00088
00092 void SingleMethodExecute();
00093
00097 void MultipleMethodExecute();
00098
00099
00100
00103 int Send(vtkDataObject *data, int remoteProcessId, int tag);
00104 int Send(int *data, int length, int remoteProcessId, int tag);
00105 int Send(unsigned long *data, int length, int remoteProcessId, int tag);
00106 int Send(char *data, int length, int remoteProcessId, int tag);
00107 int Send(float *data, int length, int remoteProcessId, int tag);
00108
00111 int Receive(vtkDataObject *data, int remoteProcessId, int tag);
00112 int Receive(int *data, int length, int remoteProcessId, int tag);
00113 int Receive(unsigned long *data, int length, int remoteProcessId, int tag);
00114 int Receive(char *data, int length, int remoteProcessId, int tag);
00115 int Receive(float *data, int length, int remoteProcessId, int tag);
00116
00120 void Start(int threadIdx);
00121
00122 protected:
00123 vtkThreadedController();
00124 ~vtkThreadedController();
00125 vtkThreadedController(const vtkThreadedController&) {};
00126 void operator=(const vtkThreadedController&) {};
00127
00128 void CreateProcessControllers();
00129 vtkThreadedControllerMessage *NewMessage(vtkDataObject *object,
00130 void *data, int dataLength);
00131 void DeleteMessage(vtkThreadedControllerMessage *message);
00132 void AddMessage(vtkThreadedControllerMessage *message);
00133 vtkThreadedControllerMessage *FindMessage(int sendId, int tag);
00134
00135
00136 vtkThreadedController *Controllers[VTK_MP_CONTROLLER_MAX_PROCESSES];
00137
00138
00139 #ifdef VTK_USE_PTHREADS
00140 pthread_t ThreadIds[VTK_MP_CONTROLLER_MAX_PROCESSES];
00141 #endif
00142 #ifdef VTK_USE_SPROC
00143 pid_t ThreadIds[VTK_MP_CONTROLLER_MAX_PROCESSES];
00144 #endif
00145
00146
00147 int LocalProcessId;
00148 int WaitingForId;
00149
00150 vtkMultiThreader *MultiThreader;
00151
00152 int MultipleMethodFlag;
00153
00154
00155
00156
00157 vtkMutexLock *MessageListLock;
00158
00159
00160
00161 vtkMutexLock *Gate;
00162
00163
00164 vtkThreadedControllerMessage *MessageListStart;
00165 vtkThreadedControllerMessage *MessageListEnd;
00166
00167
00168 FILE *LogFile;
00169
00170
00171
00172 int Send(vtkDataObject *object, void *data, int dataLength,
00173 int remoteProcessId, int tag);
00174 int Receive(vtkDataObject *object, void *data, int dataLength,
00175 int remoteProcessId, int tag);
00176
00177
00178
00179 vtkMultiProcessController *GetLocalController();
00180
00181 };
00182
00183
00184 #endif
00185
00186