Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/lib_ref/pt/ptexit.html on line 1
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/lib_ref/pt/ptexit.html on line 1
Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/lib_ref/pt/ptexit.html on line 8
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/lib_ref/pt/ptexit.html on line 8
Exit a Photon program
void PtExit( int return_code );
ph
This function
is similar to exit(),
except that PtExit() properly destroys all your application's widgets
before exiting.
In a multithreaded application, a callback can call PtExit() in one thread
while a second thread might be in the middle of an important operation,
such as writing a file. To prevent the second thread from terminating early,
call PtPreventExit() before starting
the operation, and call PtAllowExit() when
it's done.
|
Instead of calling PtPreventExit() and PtAllowExit() directly, you're better off calling PtEnter() and PtLeave() with Pt_DELAY_EXIT set in the flags, because the Pt_DELAY_EXIT flag may not cause your application to lock up
in some situations where PtPreventExit() would. For a discussion of the difference between these functions and using Pt_DELAY_EXIT, see “Exiting a multithreaded program” in the Parallel Operations chapter of the Photon Programmer's Guide.
However, if you create a widget or add a Pt_CB_APP_EXIT callback inside a PtEnter(Pt_DELAY_EXIT) section, and another thread has already called PtExit(), there's no guarantee that the new widget will be destroyed, or the new callback called. |
Before exiting, PtExit():
- Invokes all the callbacks in the Pt_CB_APP_EXIT list.
|
The callbacks in Pt_CB_APP_EXIT are called only once, even if PtExit() is called multiple times (for example by multiple threads, or recursively from a Pt_CB_APP_EXIT callback).
|
- Destroys all the application's widgets.
- Enters the delayed exit state. In this state, the function waits for the counter associated with the PtPreventExit() function and the Pt_DELAY_EXIT flag to reach zero, if it's not zero. If its value is nonzero, PtExit() unlocks the library using an equivalent of PtLeave(0) (notice that this will decrement the counter if the Pt_DELAY_EXIT flag is in effect for the calling thread) and waits until the counter reaches zero. If PtExit() is called again by another thread, that second call also unlocks the library and blocks until the first call terminates the process.
This function doesn't return.
Photon
Safety: | |
Cancellation point |
No |
Interrupt handler |
No |
Signal handler |
Not applicable |
Thread |
Yes |
PtAllowExit(), PtEnter(), PtLeave(), PtPreventExit()
exit() in
the QNX Neutrino Library Reference
Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/lib_ref/pt/ptexit.html on line 130
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/lib_ref/pt/ptexit.html on line 130