|
| iMatix home page | << | < | > | >> |
SMTVersion 2.81 |
#include "smtlib.h"
THREAD *
thread_lookup (
const char *agent_name, /* Name of agent */
const char *thread_name /* Create thread with this name */
)
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 |
{
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);
}
| | << | < | > | >> |
|