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

 

thread_lookup

#include "smtlib.h"
THREAD *
thread_lookup (
    const char *agent_name,             /*  Name of agent                    */
    const char *thread_name             /*  Create thread with this name     */
)

Synopsis

Checks whether a specific thread exists; returns the address of the thread information block, or NULL if there was an error, setting smt_errno to one of these values:
SMT NOTREADY smt_init() was not called, or failed
SMT NOSUCHTHREAD The agent/thread does not exist
If there are multiple threads (routers) with the same name, returns the earliest thread that was defined.

Source Code - (smtlib.c)

{
    SYMBOL  *dict_entry;                /*  Dictionary symbol                */
    char    *full_name;                 /*  Full thread name                 */

#if (defined (SMT_TRACE))
    trace ("thread_lookup: agent=%s thread=%s", agent_name, thread_name);
#endif
    ASSERT (agent_name);
    ASSERT (thread_name);
    if (!smt_alive)                     /*  If SMT API was not correctly     */
      {                                 /*    initialised, forget it         */
        smt_errno = SMT_NOTREADY;
        return (NULL);
      }

    /*  Check if the thread already exists                                   */
    full_name  = get_entity_name (agent_name, thread_name);
    dict_entry = sym_lookup_symbol (dict, full_name);
    if (dict_entry == NULL)
      {
         smt_errno = SMT_NOSUCHTHREAD;
         return (NULL);
      }

    /*  Get address of thread block, then find first thread defined for      */
    /*  this queue.  Usually it will be the same thread; when there are      */
    /*  multiple threads (routers) it may be a different thread.             */
    return (((THREAD *) (dict_entry-> data))-> queue-> threads.next);
}

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