| | |
| | | #include "test.h" |
| | | |
| | | using namespace std; |
| | | |
| | | int main () { |
| | | void testStruct() { |
| | | unsigned int i = 0; |
| | | |
| | | int key = 2; |
| | |
| | | } |
| | | |
| | | delete queue; |
| | | mm_destroy(); |
| | | } |
| | | |
| | | void testString() { |
| | | unsigned int i = 0; |
| | | std::ostringstream outstr; |
| | | int key = 2; |
| | | |
| | | shmstring item; |
| | | |
| | | size_t qsize = 16; |
| | | //LockFreeQueue<struct Item> *queue = QueueFactory::createQueue<struct Item> (key, qsize); |
| | | SHMQueue<shmstring> *queue = new SHMQueue<shmstring>(key, 16); |
| | | // LockFreeQueue<struct Item> queue(16); |
| | | for(i = 0; i < qsize; i++) { |
| | | outstr.seekp(0); |
| | | outstr << "hello " << i ; |
| | | if(queue->push(outstr.str().c_str())) { |
| | | cout << i << " push:" << outstr.str() << endl; |
| | | } |
| | | } |
| | | |
| | | // for(i = 0; i < qsize; i++) { |
| | | |
| | | // //queue.dequeue(item); |
| | | |
| | | // item = (*queue)[i]; |
| | | // cout << "i=" << i << ":" << item << endl; |
| | | // } |
| | | |
| | | |
| | | |
| | | struct timespec timeout = {1, 0}; |
| | | |
| | | i = 0; |
| | | while((queue->pop_timeout(item, &timeout)) ) { |
| | | cout << i << " pop:" << item << endl; |
| | | // cout << item.pic << endl; |
| | | i++; |
| | | } |
| | | |
| | | delete queue; |
| | | } |
| | | |
| | | |
| | | int main () { |
| | | testString(); |
| | | |
| | | |
| | | mm_destroy(); |
| | | return 0; |
| | | } |