ct_wakeup and the CS_DISABLE_POLL property are used in layered asynchronous applications as follows:
A layered application uses CS_DISABLE_POLL to prevent ct_poll from reporting asynchronous Client-Library routine completions.
A layered application uses ct_wakeup to let the higher layer know when a large asynchronous operation is complete.
A layered application that is using a routine to perform a large operation typically uses ct_wakeup and CS_DISABLE_POLL as follows:
The application performs any necessary initialization, installs callback routines, opens connections, and so on.
The application calls the routine that is performing the large operation.
If the application uses ct_poll to check for asynchronous completions, then the routine must disable polling. This prevents ct_poll from reporting lower-level asynchronous completions to the higher-level layer. To disable polling, the routine sets CS_DISABLE_POLL to CS_TRUE.
If the application does not call ct_poll, the routine does not need to disable polling.
The routine calls ct_callback to replace the higher-level layer’s completion callback with its own completion callback.
The routine performs its work.
The routine reinstalls the higher-level layer’s completion callback.
If polling has been disabled, the routine enables it again by setting the CS_DISABLE_POLL property to CS_FALSE.
The routine calls ct_wakeup to trigger the higher-level layer’s completion callback routine.