Using ct_wakeup and CS_DISABLE_POLL

ct_wakeup and the CS_DISABLE_POLL property are used in layered asynchronous applications as follows:

A layered application that is using a routine to perform a large operation typically uses ct_wakeup and CS_DISABLE_POLL as follows:

  1. The application performs any necessary initialization, installs callback routines, opens connections, and so on.

  2. The application calls the routine that is performing the large operation.

  3. 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.

  4. The routine calls ct_callback to replace the higher-level layer’s completion callback with its own completion callback.

  5. The routine performs its work.

  6. The routine reinstalls the higher-level layer’s completion callback.

  7. If polling has been disabled, the routine enables it again by setting the CS_DISABLE_POLL property to CS_FALSE.

  8. The routine calls ct_wakeup to trigger the higher-level layer’s completion callback routine.