Rick Stovall has proposed merging lp:~fpstovall/nrtb/circular_queue into
lp:nrtb.
Requested reviews:
NRTB Core (nrtb-core): code
For more details, see:
https://code.launchpad.net/~fpstovall/nrtb/circular_queue/+merge/78527
Added the following to the nrtb c++ common library:
Circlar_queue; a fixed size, high speed buffer/queue designed for
communications between threads.
linear_queue: an auto-expanding but somewhat slower buffer/queue designed for
communications between threads.
--
https://code.launchpad.net/~fpstovall/nrtb/circular_queue/+merge/78527
Your team NRTB Core is requested to review the proposed merge of
lp:~fpstovall/nrtb/circular_queue into lp:nrtb.
=== modified file 'common/Makefile'
--- common/Makefile 2011-08-15 03:47:28 +
+++ common/Makefile 2011-10-07 00:13:24 +
@@ -40,6 +40,8 @@
@cd point; make ${action}
@cd timer; make ${action}
@cd threads; make ${action}
+ @cd circular_queue; make ${action}
+ @cd linear_queue; make ${action}
@cd sockets; make ${action}
@cd serializer; make ${action}
@cd singleton; make ${action}
=== added directory 'common/circular_queue'
=== added file 'common/circular_queue/Makefile'
--- common/circular_queue/Makefile 1970-01-01 00:00:00 +
+++ common/circular_queue/Makefile 2011-10-07 00:13:24 +
@@ -0,0 +1,31 @@
+#***
+#This file is part of the NRTB project (https://launchpad.net/nrtb).
+#
+#NRTB 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.
+#
+#NRTB 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 NRTB. If not, see http://www.gnu.org/licenses/.
+#
+#***
+
+lib: circular_queue_test
+ @./circular_queue_test
+ @cp -v circular_queue.h ../include
+ @echo build complete
+
+circular_queue_test: circular_queue.h circular_queue_test.cpp
+ @rm -f circular_queue_test
+ g++ -c circular_queue_test.cpp -I../include
+ g++ -o circular_queue_test circular_queue_test.o ../obj/common.o ../obj/base_thread.o -lpthread
+
+clean:
+ @rm -rvf *.o circular_queue_test ../include/circular_queue.h *.log ../obj/circular_queue.o
+ @echo all objects and executables have been erased.
=== added file 'common/circular_queue/circular_queue.h'
--- common/circular_queue/circular_queue.h 1970-01-01 00:00:00 +
+++ common/circular_queue/circular_queue.h 2011-10-07 00:13:24 +
@@ -0,0 +1,174 @@
+/***
+ This file is part of the NRTB project (https://*launchpad.net/nrtb).
+
+ NRTB 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.
+
+ NRTB 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 NRTB. If not, see http://www.gnu.org/licenses/.
+
+ **/
+
+#ifndef nrtb_circular_queue_h
+#define nrtb_circular_queue_h
+
+#include iostream
+#include base_thread.h
+#include boost/circular_buffer.hpp
+
+namespace nrtb
+{
+
+/
+ * The circular_queue template is designed for use with
+ * the classic producer/consumer thread management model.
+ * The producer uses circular_queue::push() to put items
+ * in the queue as they become available, and the consumer
+ * thread calls circular_queue::park() when it is ready
+ * for the next item to work.
+ *
+ * Common uses would be for buffering outgoing or incomming
+ * messages from a communications channel, providing a feed
+ * queue for parallel threads to make full use of multi-core
+ * processors, or any case where one or more threads are
+ * passing data to another set of threads.
+/
+template class T
+class circular_queue
+{
+public:
+class queue_not_ready: public base_exception {};
+
+/*
+ * creates the queue with the specified
+ * number of elements. All memory is allocated
+ * at construction to minimize delays at runtime.
+*/
+circular_queue(int size);
+
+/*
+