vtkThreadedController::Barrier() not working?
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
Here is a sample code showing that the Barrier() method does not work (at least on my computer). The threads sometimes get stuck at the Barrier() invocation. I use microsoft .net environment. Note that on my computer, it seems that after the program is build, its first execution shows the problem. But the following executions are succesfull most of the time.
********* BEGIN CODE***************
#include <vtkThreadedController.h>
// This will be called by all processes void MyMain( vtkMultiProcessController *controller, void *arg ) { int myid, numProcs; myid = controller->GetLocalProcessId(); numProcs = controller->GetNumberOfProcesses(); cout<<numProcs<<" Processes"<<endl; controller->Barrier(); cout<<"Barrier Passed !"<<endl; }
int main( int argc, char* argv[] ) { vtkThreadedController *controller; controller = vtkThreadedController::New(); controller->Initialize(0, 0); controller->SetSingleMethod(MyMain, 0); controller->SetNumberOfProcesses(4); controller->SingleMethodExecute(); controller->Finalize(); controller->Delete(); return 0; } ****************** End Code ****************