macsim/src/noc/msgqueue.c
// Search for the first message with matching rank and remove it from the queue,
// even if it is in the middle
Search for the first message with matching rank and remove it from the queue,
even if it is in the middle
Search for the first message with matching rank and remove it from the queue even if it is in the middle
bool msg_dequeue_rank(msg_queue_t *queue, uint8_t *buf, uint32_min_t *len, rank_t rank)
{
    msg_queue_entry_t *p=0, *h=queue->head;
    while (h)
    {
	if (h->rank == rank)
	{
	    *len = h->len;
	    memcpy(buf, h->content, h->len);
	    if (p)
		p->next = h->next;
	    else
		queue->head = h->next;
	    if (!h->next)
	        queue->tail = p;
	    free(h);
	    queue->count--;
	    return 1;
	}
	p = h;
	h = h->next;
    }
    return 0;
}
bool msg_dequeue_rank ( msg_queue_t * queue , uint8_t * buf , uint32_min_t * len , rank_t rank ) { msg_queue_entry_t * p = 0 , * h = queue -> head ; while ( h ) { if ( h -> rank == rank ) { * len = h -> len ; memcpy ( buf , h -> content , h -> len ) ; if ( p ) p -> next = h -> next ; else queue -> head = h -> next ; if ( ! h -> next ) queue -> tail = p ; free ( h ) ; queue -> count -- ; return 1 ; } p = h ; h = h -> next ; } return 0 ; }
Search for the first message with matching rank and remove it from the queue,
even if it is in the middle
Search for the first message with matching rank and remove it from the queue even if it is in the middle