Line data Source code
1 : /* 2 : * vr_queue.c -- queue implementation for vrouter 3 : * 4 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 5 : * Copyright Contributors to the OpenSDN project 6 : */ 7 : #include <vr_os.h> 8 : #include "vr_queue.h" 9 : 10 : void 11 0 : vr_queue_init(struct vr_qhead *head) 12 : { 13 0 : head->q_first = NULL; 14 0 : return; 15 : } 16 : 17 : void 18 2863 : vr_queue_enqueue(struct vr_qhead *head, struct vr_qelem *p) 19 : { 20 2863 : struct vr_qelem *elem = head->q_first; 21 : 22 2863 : p->q_next = NULL; 23 : 24 2863 : if (!elem) { 25 2862 : head->q_first = p; 26 2862 : return; 27 : } 28 : 29 1 : while (elem && elem->q_next) 30 0 : elem = elem->q_next; 31 : 32 1 : elem->q_next = p; 33 1 : return; 34 : } 35 : 36 : struct vr_qelem * 37 5725 : vr_queue_dequeue(struct vr_qhead *head) 38 : { 39 5725 : struct vr_qelem *elem = head->q_first; 40 : 41 5725 : if (elem) 42 2863 : head->q_first = elem->q_next; 43 : 44 5725 : return elem; 45 : } 46 : 47 : bool 48 5726 : vr_queue_empty(struct vr_qhead *head) 49 : { 50 5726 : if (head->q_first) 51 1 : return false; 52 5725 : return true; 53 : }