diff --git a/include/tr/queue.h b/include/tr/queue.h index 9391835..47f2714 100644 --- a/include/tr/queue.h +++ b/include/tr/queue.h @@ -52,6 +52,7 @@ TR_INSTANCE_INIT(TR_Queue); TR_CLASSVARS_DECL(TR_Queue) {}; void TR_queuePut(TR_Queue, void *); +void TR_queuePutFirst(TR_Queue, void *); void * TR_queueGet(TR_Queue); #define TR_queueEmpty(this) (0 >= (this)->nmsg) diff --git a/src/queue/Makefile.am b/src/queue/Makefile.am index 838dd53..1e8973e 100644 --- a/src/queue/Makefile.am +++ b/src/queue/Makefile.am @@ -5,5 +5,5 @@ AM_CFLAGS += -I../../include/ noinst_LTLIBRARIES = libqueue.la -libqueue_la_SOURCES = queue.c get.c put.c +libqueue_la_SOURCES = queue.c get.c put.c put_first.c libqueue_la_CFLAGS = $(AM_CFLAGS) diff --git a/src/queue/put_first.c b/src/queue/put_first.c new file mode 100644 index 0000000..be7b57b --- /dev/null +++ b/src/queue/put_first.c @@ -0,0 +1,37 @@ +/** + * \file + * + * \author Georg Hopp + * + * \copyright + * Copyright © 2014 Georg Hopp + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "trbase.h" +#include "tr/queue.h" + +void +TR_queuePutFirst(TR_Queue this, void * msg) +{ + TR_Queue current_first = this->first; + + this->first = TR_new(TR_Queue); + this->first->next = current_first; + this->first->msg = msg; + this->nmsg++; +} + +// vim: set ts=4 sw=4: