[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]


E.5 cma Alert Example

A thread control and condition example is shown in Example E-1.

Example E-1 cma Alert Example

/*
 * cma Alert Example
 */
/*
 * Outermost alert scope
 */
{
 .
 .
 .
cma_t_alert_state       outer_a_s;
 .
 .
 .
/*
 * Create a nested alert scope, saving the previous setting.  In this
 * scope, alerts will be disabled.
 */
cma_alert_disable_general (&outer_a_s);
/*
 * Now alerts are disabled.
 */
 .
 .
 .
/*
 * Create another nested scope.  In this scope, alerts will be enabled.
 */
{
        cma_t_alert_state      inner_a_s;
        .
        .
        .
        cma_alert_enable_general (&inner_a_s);
        /*
         * Now alerts are enabled.
         */
        .
        .
        .
        /*
         * Create another nested scope.  In this scope, we will be enabling
         * asynchronous alerts.
         */
        {
                cma_t_alert_state       async_a_s;
                .
                .
                .
                /*
                 * First capture the alert state, so it can be restored later.
                 */
                cma_alert_disable_asynch (&async_a_s);
                /*
                 * Now enable asynchronous alerts.
                 */
                cma_alert_enable_asynch ();
                /*
                 * Now asynchronous alerts are enabled.
                 */
                 .
                 .
                 .
                /*
                 * Now restore the previous alert state, which disables
                 * asynchronous alerts.
                 */
                cma_alert_restore (&async_a_s);
                /*
                 * Now asynchronous alerts are disabled; synchronous alerts
                 * are still enabled.
                 */
        }
         .
         .
         .
        /*
         * There is no requirement to restore all alert scopes.  However, you
         * may not restore an inner scope after restoring an outer one.
         */
}
 .
 .
 .
/*
 * Restore the original alert state.
 */
cma_alert_restore (&outer_a_s);
 .
 .
 .
}



[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]