#include <toast/async/locking_queue.hpp>
This queue takes care of the synchronization of the queue for you. It uses std::lists as smart storage so that no copying is required to get the data in and out of the queue.
Public Member Functions | |
void | push (std::list< T > &l) |
push some data on to the queue. | |
void | push (T const &t) |
simply a convenience wrapper around the other push | |
void | pop_one (std::list< T > &l) |
if there are any elements in the queue one is popped into the list | |
void | pop (std::list< T > &l) |
if there are any elements in the queue, all of them are popped into the list. |
void toast::async::locking_queue< T >::push | ( | std::list< T > & | l | ) | [inline] |
push some data on to the queue.
It doesn't matter how many elements are in the list. All of them are pushed. Upon return the list will contain no elements.
Referenced by toast::async::locking_queue< T >::push().
void toast::async::locking_queue< T >::pop_one | ( | std::list< T > & | l | ) | [inline] |
if there are any elements in the queue one is popped into the list
Only use this function if you absolutely need to only pop one element. If you can pop them all, you may reduce the amount of locking significantly.
no T pop() was provided as it would require external locking around it and a call to empty() which is not provided for the same reason. Without this external locking there would be a race between calls to empty() and pop().
void toast::async::locking_queue< T >::pop | ( | std::list< T > & | l | ) | [inline] |
if there are any elements in the queue, all of them are popped into the list.
You should use this by default. Use pop_one if you must limit yourself to one element for some reason.