PtQuitMainLoop()

Cause PtMainLoop() in the calling thread to return

Synopsis:

int PtQuitMainLoop( void );

Library:

ph

Description:

This function causes PtMainLoop() in the calling thread to return right after it finishes processing the current event.


Note: PtQuitMainLoop() doesn't affect any modal operations that the thread is currently doing; if you call PtQuitMainLoop() from within a modal loop, there's no way for PtMainLoop() to return until after the modal loop has completed.

Keep in mind that if you let your main() function return, exit() is called and your application is terminated without letting any widgets or threads do any cleaning up. It's better to call PtExit() instead -- the main purpose of PtQuitMainLoop()is to let you terminate threads running PtMainLoop() without terminating the application.

To ensure your application doesn't terminate, put a pthread_exit() call after the PtMainLoop() call in main(). In PhAB, changes to main() get overwritten by PhAB, so you should declare a global header for your application and map PtMainLoop() to your own function using a macro. For example:

    #undef PtMainLoop
    void MyMainLoop( void ) {
       PtMainLoop();
       pthread_exit(NULL);
       }

Returns:

0
Success.
-1
The thread has already called PtQuitMainLoop().

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PtExit(), PtMainLoop()

Threads in the Parallel Operations chapter of the Photon Programmer's Guide