| iMatix home page
| << | < | > | >>
SMT Logo SMT
Version 2.81

 

queue_destroy

#include "smtlib.h"
int
queue_destroy (
    QUEUE *queue                        /*  Queue to destroy                 */
)

Synopsis

Deletes any events in the event queue and then destroys the queue and all its threads. Returns 0 when successfully completed. In case of error, returns -1 and sets smt_errno to one of these values:
SMT NOTREADY smt_init() was not called, or failed
SMT NOSUCHQUEUE The event queue is not defined

Source Code - (smtlib.c)

{
#if (defined (SMT_TRACE))
    trace ("queue_destroy");
#endif
    ASSERT (queue);
    if (!smt_alive)                     /*  If SMT API was not correctly     */
      {                                 /*    initialised, forget it         */
        smt_errno = SMT_NOTREADY;
        return (-1);
      }

    /*  Delete all events in the queue                                       */
    while (event discard (queue, NULL) == 0);

    /*  Destroy all threads defined for the queue                            */
    while (queue-> threads.next != &queue-> threads)
        thread destroy (queue-> threads.next, FALSE);

    /*  We have to be a little careful or sym_delete_symbol () will          */
    /*  try to release the symbol's data area; the data area points          */
    /*  to our node, which we want to release ourselves.                     */
    queue-> symbol-> data = NULL;
    sym_delete_symbol (dict, queue-> symbol);

    /*  Now delete the queue itself                                          */
    node_destroy (queue);
    return (0);
}

| << | < | > | >> iMatix Copyright © 1996-99 iMatix Corporation