mpiThreadStatus
Declaration
MPI_DECL1 MPI_RESULT MPI_DECL2 mpiThreadStatus(MPIThread thread, MPIThreadStatus *status);
Required Header: stdmpi.h
Change History: Added in 04.00.
Description
mpiThreadStatus writes to status the current status of an MPIThread object.
thread | A handle to the MPIThread object. |
---|---|
status | A pointer to an MPIThreadStatus variable where the thread object’s status is written. |
Sample Code
MPI_RESULT MPI_DECL2 helloThreadMain(void* threadData) { /* print event type to screen. */ printf("Hello from another thread.\n" " threadData = 0x%08x", threadData); return MPIMessageOK; } /* Wait for a thread to end */ MPI_RESULT threadJoin(MPIThread thread) { MPIThreadStatus status; MPI_RESULT returnValue = MPIMessageOK; while (returnValue == MPIMessageOK) { returnValue = mpiThreadStatus(thread, &status); if ((returnValue == MPIMessageOK) && (status.active == FALSE)) { break; } mpiPlatformSleep(10); } return returnValue; } void sayHello() { MPIThread thread; MPI_RESULT returnValue; returnValue = mpiThreadCreate(&thread, NULL); msgCHECK(returnValue); returnValue = mpiThreadStart(thread, helloThreadMain, NULL); msgCHECK(returnValue); returnValue = threadJoin(thread); msgCHECK(returnValue); returnValue = mpiThreadDelete(thread); msgCHECK(returnValue); }