| iMatix home page | << | < | > | >> |
SMT Version 2.81 |
#include "smtlib.h" QUEUE * queue_create ( AGENT *agent, /* Parent agent block, or null */ int max_events /* Max. events; 0 = no limit */ )
Creates an event queue, and returns a handle to the created queue. Event queues are unnamed but attached to a agent within an agent. Queue can also be 'floating', i.e. not attached to a agent. This is useful for foreign programs. If you specify a agent, the queue is attached to that agent. If the agent argument is null, the queue is left floating. You always refer to a queue using its address (within the owning process) or QID handle (within any process). The current implementation uses a linked list in heap memory, so QID handles are only valid within the process. Future implementations may use other types of shared memory including connections across a communications protocol. Returns a pointer to the created QUEUE block. In case of error, returns null and sets smt_errno to one of these values:
SMT NOTREADY | smt_init() was not called, or failed |
SMT OUTOFMEMORY | Not enough heap memory left |
{ static long top_id = 0; /* We number queues from 1 up */ QID qid; /* Created queue */ SYMBOL *dict_entry; /* Dictionary symbol */ QUEUE *queue; /* Queue information block */ #if (defined (SMT_TRACE)) trace ("queue_create: agent=%s", agent? agent-> name: "<none>"); #endif if (!smt_alive) /* If SMT API was not correctly */ { /* initialised, forget it */ smt_errno = SMT_NOTREADY; return (NULL); } qid.node = 0; /* Queues are local for now */ qid.ident = ++top_id; /* First queue has id = 1 */ dict_entry = sym_create_symbol (dict, get_queue_name (&qid), NULL); if (dict_entry == NULL) { smt_errno = SMT_OUTOFMEMORY; return (NULL); } /* Allocate a QUEUE block and attach it to the queue list */ queue = (QUEUE *) node_create (agent? &agent-> queues: NULL, sizeof (QUEUE)); if (queue == NULL) { sym_delete_symbol (dict, dict_entry); smt_errno = SMT_OUTOFMEMORY; return (NULL); } /* Point the dictionary entry to the queue information block */ dict_entry-> data = queue; /* Now initialise the queue info block fields and list heads */ node_reset (&queue-> events); node_reset (&queue-> threads); queue-> symbol = dict_entry; queue-> agent = agent; queue-> qid = qid; queue-> max_events = max_events; queue-> shutdown = FALSE; return (queue); }
| << | < | > | >> | Copyright © 1996-99 iMatix Corporation |