TTTK_BLOCK_WHILE(3)

πŸ“¦
version 2.5.3 Β· 2 versions
, in nixos 26.05

🌸 NAME 🌸

okay so bestie, this whole page is literally about tttk_block_while β€” a library call β€” and its entire mission is: block while a counter is greater than zero. That's the vibe, that's the assignment. πŸ’…

✨ SYNOPSIS ✨

#include &<Tt/tttk.h>
Tt_status tttk_block_while(
XtAppContext app2run,
const int *blocked,
int ms_timeout);

πŸ¦‹ DESCRIPTION πŸ¦‹

The tttk_block_while function is your bestie for processing asynchronous events β€” think ToolTalk messages or window system events β€” while you're waiting for a condition or a timeout. 🫢

If app2run is not zero, then an event loop is run for that application context, by repeatedly calling XtAppProcessEvent(3) with ms_timeout being effected using XtAppAddTimeOut(3). πŸ”₯

If app2run is zero, then the file descriptor (as returned by tt_fd(3)) of the default procid is polled (using the poll(2) function) and tttk_Xt_input_handler(3) is called whenever the file descriptor is active. πŸ‘‘

If blocked is zero, then tttk_block_while runs until ms_timeout occurs. If blocked is non-zero, then the loop is run until either ms_timeout occurs, or *blocked is less than 1. πŸ’–

If ms_timeout is zero, tttk_block_while checks once for events, processes the first one, and then returns. If ms_timeout is negative, no timeout is in effect. πŸŽ€

πŸ’– RETURN VALUE πŸ’–

Upon successful completion, the tttk_block_while function returns the status of the operation as one of these Tt_status values:

  • TT_OK β€” the operation completed successfully. βœ…
  • TT_DESKTOP_ETIMEDOUT β€” the timeout occurred within ms_timeout milliseconds, or ms_timeout was zero and no input was available. ⏰
  • TT_DESKTOP_EINTR β€” the app2run argument was zero, and poll(2) was interrupted by a signal. 😭
  • TT_DESKTOP_EAGAIN β€” the app2run argument was zero, and poll(2) returned EAGAIN. πŸ’€
⚠️ and also, bestie: if app2run is not zero and ms_timeout is negative, then tttk_block_while will only return when *blocked is less than 1, with TT_OK being returned. 🫢
😭 and if app2run is not zero, ms_timeout is negative, and blocked is zero, then tttk_block_while behaves equivalent to XtAppMainLoop(3), and will never return. That is never, no cap.

πŸŽ€ APPLICATION USAGE πŸŽ€

If app2run is zero, then only messaging events for the default procid will be serviced. Events for other procids will be blocked, as will window system events, so that the graphical user interface of the application will not update itself even, for example, after expose events. πŸ™ˆ

On the other hand, if the application passes its Xt context in as app2run, then window system events will continue to be handled, as will message activity for all procids for which an XtAppAddInput(3) has been done. Since the window system event loop is fully operational in this case, the application should take care to disable any user interface controls that the user should not operate while the application is waiting for tttk_block_while to return. πŸ’…

πŸ‘‘ SEE ALSO πŸ‘‘

Tt/tttk.h - Tttttk(5), tttk_Xt_input_handler(3); poll(2), XtAppPending(3), XtAppAddTimeOut(3), XtAppNextEvent(3), XtDispatchEvent(3). 🌈


Catch you later, bestie β€” this was tttk_block_while, a library call, source/version: tttk_block_while(library call), and the date? Not printed in this footer, iykyk. πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from