consumer.cpp

Go to the documentation of this file.
00001 
00007 #include <string>
00008 #include <iostream>
00009 #include <sstream>
00010 #include <math.h>
00011  
00012 #include "shm_segment.h"
00013 #include "shm_ptr.h"
00014 #include "scoped_lock.h"
00015 #include "shm_allocator.h"
00016 #include "shm_queue.h"
00017 #include "shm_message.h"
00018  
00019 using namespace std;
00020  
00021 int main(int argc, char*argv[])
00022 {
00023   std::cout 
00024     << "enter a shared memory id : " 
00025     << std::flush;
00026   std::string line;
00027   std::getline( std::cin, line );
00028   long shmid = atol( line.c_str() );
00029   shm_segment seg( (int)shmid, 01640 ) ; 
00030   shm_allocator a( seg );
00031   shm_queue<shm_message> q( a );
00032 
00033   while ( true ) {
00034       std::cout 
00035     << "Queue size : "
00036     << q.size()
00037     << endl;
00038       shm_ptr<shm_message> p = q.pop();
00039       shm_message* m = p.get(seg);
00040       std::cout 
00041     << "Message " 
00042     << m->sequence_num 
00043     << " " 
00044     << m->message.get(seg) 
00045     << "\n";
00046       //      a.free(m->message.get(seg));
00047       //      m->~Message();
00048       //      operator delete(m, a);
00049     }
00050 }
00051  
00052 /*
00053  * $Log: consumer.cpp,v $
00054  * Revision 1.1.1.1  2006/08/30 12:14:46  oommoo
00055  * Initial checkin of project library
00056  *
00057  *
00058  * SharedMemory notes from :
00059  *
00060  * http://home.earthlink.net/~joshwalker1/writing/SharedMemory.html
00061  *
00062  */

Project shmq hosted by   SourceForge.net
Documentation generated on Sat Sep 2 10:07:40 2006 for shmq by   doxygen.org 1.4.6