| iMatix home page | << | < | > | >> |
SMT Version 2.81 |
#include "smtlib.h" int thread_destroy ( THREAD *thread, /* Thread to destroy */ Bool cleanup /* Delete queue if last thread */ )
Destroys the thread. If this was the last instance of a router thread, destroys the parent queue as well, if the cleanup argument is TRUE. Returns 0 if successfully completed, else returns -1 and sets smt_errno to one of these values:
SMT NOTREADY | smt_init() was not called, or failed |
{ AGENT *agent; /* Agent information block */ QUEUE *queue; /* Queue information block */ #if (defined (SMT_TRACE)) trace ("thread_destroy: thread=%s", thread-> name); #endif ASSERT (thread); if (!smt_alive) /* If SMT API was not correctly */ { /* initialised, forget it */ smt_errno = SMT_NOTREADY; return (-1); } queue = thread-> queue; /* Get parents for thread */ agent = queue-> agent; /* 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. */ thread-> symbol-> data = NULL; sym_delete_symbol (dict, thread-> symbol); /* Destroy event for the thread, if we still need to */ if (thread-> event) /* NULL = no event for thread */ event destroy (thread-> event); /* Delete the thread */ thread_unlink (thread); /* Remove thread from active */ mem_free (thread-> tcb); /* Free allocated TCB, */ mem_free (thread-> LR_stack); /* and sub-dialog stack */ mem_strfree (&thread-> name); node_destroy (thread); /* Destroy queue if last thread, and we are asked to clean-up */ if (queue-> threads.next == &queue-> threads && cleanup) queue destroy (queue); ASSERT (agent-> cur_threads > 0); agent-> cur_threads--; cur_threads--; /* Keep count of threads */ return (0); }
| << | < | > | >> | Copyright © 1996-99 iMatix Corporation |