Esempio n. 1
0
void* DLLCALL msgQueuePeek(msg_queue_t* q, long timeout)
{
	link_list_t*	list = msgQueueReadList(q);

	if(list_wait(list,timeout))
#if defined(LINK_LIST_THREADSAFE)
		listSemPost(list)	/* Replace the semaphore we just cleared */
#endif
		;

	return listNodeData(listFirstNode(list));
}
Esempio n. 2
0
BOOL DLLCALL msgQueueWait(msg_queue_t* q, long timeout)
{
	BOOL			result;
	link_list_t*	list = msgQueueReadList(q);

	if((result=list_wait(list,timeout))==TRUE)
#if defined(LINK_LIST_THREADSAFE)
		listSemPost(list)	/* Replace the semaphore we just cleared */
#endif
		;

	return(result);
}
Esempio n. 3
0
static list_node_t* DLLCALL list_add_node(link_list_t* list, list_node_t* node, list_node_t* after)
{
    if(list==NULL)
        return(NULL);

    listLock(list);

    node->list = list;
    if(after==LAST_NODE)					/* e.g. listPushNode() */
        after=list->last;
    node->prev = after;

    if(after==list->last)					/* append to list */
        list->last = node;
    if(after==FIRST_NODE) {					/* insert at beginning of list */
        node->next = list->first;
        if(node->next!=NULL)
            node->next->prev = node;
        list->first = node;
    } else {
        if(after->next!=NULL) {
            after->next->prev = node;
            node->next = after->next;
        }
        after->next = node;
    }

    list->count++;

    listUnlock(list);

#if defined(LINK_LIST_THREADSAFE)
    if(list->flags&LINK_LIST_SEMAPHORE)
        listSemPost(list);
#endif

    return(node);
}