Click here to Skip to main content
15,892,072 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
the kind of program that i actually want to write is:there are different data that comes in from a server and we have to send that data to another server,and among that data we have to filter data,make some internal calculation from our side and then we have to send,for that my idea is to create a queue ,where data can reside for a fixed time..we will do internal calculation and send and at that time other data that comes will reside in another queue but cant get idea ,about how to implement queue in c++?
Posted
Comments
Jim Jos 24-May-12 0:59am    
Are you using C++.net or VC6 or some other C++? There are multiple data structures available to implement a queue.. Your data is coming as a string or an object or binary?
enhzflep 24-May-12 2:48am    
[Solution 1 converted to Comment Reply]

hey jimjos,i am using VC++.net,my data is coming as array.
Sergey Alexandrovich Kryukov 24-May-12 3:07am    
What's the problem?
--SA
Malli_S 24-May-12 3:08am    
Have you tried STL ?

Sine you're using c++, why not just use one of the data-types from the STL?
You've got std::queue, which appears likely to be just what you need.

If you can't use an existing one, it's not that difficult to implement a queue yourself. Conceptually, it's just a list - a list in which you must add new items to the end(tail) and with which you must remove elements from the start(head).

Here's an example of std::queue in use: http://www.cplusplus.com/reference/stl/queue/pop/[^]
 
Share this answer
 
Hi,

Firstly you can use : http://en.wikipedia.org/wiki/Message_queue

This means that the messages to be sent to the server must be queued (so that they can be sent once the connection is available).
It must be relatively simple to use from C++ on Win32.

Maybe it will help you:
Using WIN32 Message Queue in C++ / WIN32 Multithreaded Applications[^]
http://www.zeromq.org/blog:multithreaded-server[^]
http://tim.klingt.org/boost_lockfree/[^]
http://www.dinkum.nl/software/multithreading/doc/msgqueue.php[^]

Regards,
Alex
 
Share this answer
 
Use std::deque[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900