------------------------------------------------------------
revno: 25
committer: Rick Stovall <fpstovall>
branch nick: ricks-sprint-003
timestamp: Mon 2013-08-26 22:17:50 -0400
message:
  Checkpoint. Still having some trouble wiht the ipc_channel queue setup.
modified:
  cpp/common/ipc_channel/ipc_channel.cpp
  cpp/common/ipc_channel/ipc_channel.h
  cpp/common/ipc_channel/ipc_channel_test.cpp


--
lp:~fpstovall/nrtb/fps-sprint-003
https://code.launchpad.net/~fpstovall/nrtb/fps-sprint-003

Your team NRTB Core is subscribed to branch lp:~fpstovall/nrtb/fps-sprint-003.
To unsubscribe from this branch go to 
https://code.launchpad.net/~fpstovall/nrtb/fps-sprint-003/+edit-subscription
=== modified file 'cpp/common/ipc_channel/ipc_channel.cpp'
--- cpp/common/ipc_channel/ipc_channel.cpp	2013-08-24 01:23:10 +0000
+++ cpp/common/ipc_channel/ipc_channel.cpp	2013-08-27 02:17:50 +0000
@@ -22,6 +22,25 @@
 
 namespace nrtb 
 {
-
+abs_ipc_record::abs_ipc_record(ipc_queue& q): 
+  return_to(q) {};
+
+ipc_queue& ipc_channel_manager::get(std::string name)
+{
+  return channels[name];
+};
+  
+ipc_channel_manager::iterator ipc_channel_manager::begin()
+{
+  return channels.begin();
+};
+
+ipc_channel_manager::iterator ipc_channel_manager::end()
+{
+  return channels.end();
+}
+
+
+  
 } // namespace nrtb
 

=== modified file 'cpp/common/ipc_channel/ipc_channel.h'
--- cpp/common/ipc_channel/ipc_channel.h	2013-08-24 01:23:10 +0000
+++ cpp/common/ipc_channel/ipc_channel.h	2013-08-27 02:17:50 +0000
@@ -32,7 +32,7 @@
   
 class abs_ipc_record;
 
-typedef std::unique_ptr<abs_ipc_record> ipc_record_p;
+typedef abs_ipc_record* ipc_record_p;
 
 typedef linear_queue<ipc_record_p> ipc_queue;
 
@@ -45,7 +45,9 @@
  */
 class abs_ipc_record
 {
-  ipc_queue & return_address;
+public:
+  ipc_queue & return_to;
+  abs_ipc_record(ipc_queue & q);
 };
 
 /** ipc_channel_manager provides a place to stash ipc_queues

=== modified file 'cpp/common/ipc_channel/ipc_channel_test.cpp'
--- cpp/common/ipc_channel/ipc_channel_test.cpp	2013-08-24 01:23:10 +0000
+++ cpp/common/ipc_channel/ipc_channel_test.cpp	2013-08-27 02:17:50 +0000
@@ -22,11 +22,55 @@
 using namespace nrtb;
 using namespace std;
 
+class main_msg: public abs_ipc_record
+{
+public:  
+  using abs_ipc_record::abs_ipc_record;
+  int msg_num;
+};
+
+class worker_msg: public abs_ipc_record
+{
+public:
+  using abs_ipc_record::abs_ipc_record;
+  int ret_num;
+};
+
+int worker(int limit)
+{
+  global_ipc_channel_manager & ipc 
+    = global_ipc_channel_manager::get_reference();
+  ipc_queue & in = ipc.get("worker");
+  ipc_queue & out = ipc.get("main");
+  int total(0);
+  while (total < limit)
+  {
+    main_msg & msg = static_cast<main_msg>(in.pop());
+    worker_msg_p outmsg(new worker_msg(in));
+    outmsg->ret_num = msg->msg_num;
+    out.push(outmsg);
+    total++;
+  };
+};
 
 int main()
 {
   cout << "=========== IPC Channel test ============="
     << endl;
+    
+  global_ipc_channel_manager & ipc 
+    = global_ipc_channel_manager::get_reference();
+  ipc_queue & in = ipc.get("main");
+  ipc_queue & out = ipc.get("worker");
+  int limit = 100;
+  // start the worker here.
+  
+  for (int i(0); i<limit; i++)
+  {
+    main_msg_p msg(new main_msg(in));
+    msg->msg_num = i;
+    out.push(msg);
+  };
 
   cout << "=========== IPC Channel test complete ============="
     << endl;

_______________________________________________
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

Reply via email to