[Nrtb-core] [Merge] lp:~fpstovall/nrtb/circular_queue into lp:nrtb

2011-10-06 Thread Rick Stovall
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);
+
+/*
+

[Nrtb-core] [Blueprint nrtb-circular-queue] Thread-safe circular buffer/queue

2011-10-06 Thread Rick Stovall
Blueprint changed by Rick Stovall:

Whiteboard changed:
  The new circular_queue template class will in the nrtb_common lib and will 
provide the following interface:
- constructor and destructor 
-push // put in the queue
-pull   // get from the queue
-park  // blocks the calling thread until there is data to be processed, 
returns a queue item.
-clear  // clears the queue
-resize // sets the queue size
-size // returns the number of elements in the queue.
+ constructor and destructor
+    push // put in the queue
+    pull   // get from the queue
+    park  // blocks the calling thread until there is data to be processed, 
returns a queue item.
+    clear  // clears the queue
+    resize // sets the queue size
+    size // returns the number of elements in the queue.
+ 
+ Also include a linear_queue template which has the same interface as
+ above without the resize method. The linear queue is a bit slower, but
+ will expand as needed to handle the load.
+ 
+ Circular queue is best suited for tight, high speed links between
+ threads where you can reasonably predict the high-water marks, while
+ linear queue is better suited where speed is less important and the
+ queue may need to grow.

-- 
Thread-safe circular buffer/queue
https://blueprints.launchpad.net/nrtb/+spec/nrtb-circular-queue

___
Mailing list: https://launchpad.net/~nrtb-core
Post to : nrtb-core@lists.launchpad.net
Unsubscribe : https://launchpad.net/~nrtb-core
More help   : https://help.launchpad.net/ListHelp


Re: [Nrtb-core] [Merge] lp:~fpstovall/nrtb/circular_queue into lp:nrtb

2011-10-06 Thread Rick Stovall
Review: Approve merge test

Test merge to the alpha branch has been completed. A test build of common was 
completed and all unit tests were reviewed and verified to have completed 
correctly. There were no issues found.
-- 
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.

___
Mailing list: https://launchpad.net/~nrtb-core
Post to : nrtb-core@lists.launchpad.net
Unsubscribe : https://launchpad.net/~nrtb-core
More help   : https://help.launchpad.net/ListHelp