📄 programme.cpp
字号:
#include "programme.h"
void process(vtkMultiProcessController* controller, void* vtkNotUsed(arg))
{
taskFunction task;
int myId = controller->GetLocalProcessId();
// Chose the appropriate task (see task3.cxx and task4.cxx)
if ( myId == 0 )
{
task = task1;
}
else
{
task = task2;
}
// Run the tasks (see task3.cxx and task4.cxx)
(*task)();
}
int main( int argc, char* argv[] )
{
// Note that this will create a vtkMPIController if MPI
// is configured, vtkThreadedController otherwise.
vtkMultiProcessController* controller = vtkMultiProcessController::New();
controller->Initialize(&argc, &argv);
// When using MPI, the number of processes is determined
// by the external program which launches this application.
// However, when using threads, we need to set it ourselves.
if (controller->IsA("vtkThreadedController"))
{
// Set the number of processes to 2 for this example.
controller->SetNumberOfProcesses(2);
}
int numProcs = controller->GetNumberOfProcesses();
if (numProcs != 2)
{
cerr << "This example requires two processes." << endl;
controller->Finalize();
controller->Delete();
return 1;
}
// Execute the function named "process" on both processes
controller->SetSingleMethod(process, 0);
controller->SingleMethodExecute();
// Clean-up and exit
controller->Finalize();
controller->Delete();
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -