#include <shm_queue.h>
Collaboration diagram for shm_queue< T >:
Public Member Functions | |
shm_queue (shm_allocator &allocator, const size_t maxsize) | |
shm_queue (shm_allocator &allocator) | |
~shm_queue () | |
void * | operator new (size_t s, shm_allocator &a) |
void | operator delete (void *p, shm_allocator &a) |
void | push (shm_ptr< T > obj) |
shm_ptr< T > | pop () |
void | lock_head () |
void | unlock_head () |
void | lock_tail () |
void | unlock_tail () |
size_t | size () const |
Private Member Functions | |
shm_queue (const shm_queue ©) | |
shm_queue & | operator= (const shm_queue &rhs) |
Private Attributes | |
size_t | MaxQueueSize |
shm_ptr< shm_queue_header< T > > | shm_header |
shm_allocator & | a |
const shm_segment & | seg |
This queue template can be used for basic FIFO operation. It uses the shared memory segment allocator to construct queue nodes and POSIX mutex for locks and condition variables.
The shm_queue_header and the shm_queue_node classes reside in shared memory.
Definition at line 135 of file shm_queue.h.
shm_queue< T >::shm_queue | ( | shm_allocator & | allocator, | |
const size_t | maxsize | |||
) | [inline] |
constructor requires an allocator and a maximum queue depth.
allocator | used to obtain memory | |
maxsize | number of elements in this queue |
Definition at line 145 of file shm_queue.h.
References shm_queue< T >::a, shm_ptr< T >::reset(), shm_queue< T >::seg, and shm_queue< T >::shm_header.
Here is the call graph for this function:
shm_queue< T >::shm_queue | ( | shm_allocator & | allocator | ) | [inline] |
constructor requires an allocator
allocator | used to obtain memory |
Definition at line 159 of file shm_queue.h.
References shm_queue< T >::a, shm_segment::get_base(), shm_allocator::get_overhead(), shm_ptr< T >::reset(), shm_queue< T >::seg, and shm_queue< T >::shm_header.
Here is the call graph for this function:
Definition at line 171 of file shm_queue.h.
void* shm_queue< T >::operator new | ( | size_t | s, | |
shm_allocator & | a | |||
) | [inline] |
Definition at line 173 of file shm_queue.h.
References shm_queue< T >::a, and shm_allocator::alloc().
Here is the call graph for this function:
void shm_queue< T >::operator delete | ( | void * | p, | |
shm_allocator & | a | |||
) | [inline] |
Definition at line 177 of file shm_queue.h.
References shm_queue< T >::a, and shm_allocator::free().
Here is the call graph for this function:
push a node into the queue
Obtain queue head lock and insert object into the front of the queue. If the queue was empty unlock the tail.
obj | shared segment pointer of object to enqueue |
Definition at line 249 of file shm_queue.h.
References shm_queue< T >::a, shm_queue_node< T >::data, shm_ptr< T >::get(), shm_segment::get_base(), shm_allocator::get_overhead(), shm_queue_header< T >::head, shm_queue_header< T >::head_lock, shm_queue_node< T >::next, shm_ptr< T >::off(), shm_queue_node< T >::prev, shm_queue_header< T >::ready_for_pop, shm_ptr< T >::reset(), shm_queue< T >::seg, shm_queue_header< T >::size, and shm_queue_header< T >::tail.
Referenced by main().
Here is the call graph for this function:
pop a node from the queue
Obtain queue tail lock and remove object from the back of the queue. If the resulting queue is empty lock the tail and set head to null.
Definition at line 302 of file shm_queue.h.
References shm_queue< T >::a, shm_queue_node< T >::data, shm_ptr< T >::get(), shm_segment::get_base(), shm_allocator::get_overhead(), shm_queue_header< T >::head, shm_ptr< T >::off(), shm_queue_node< T >::prev, shm_queue_header< T >::ready_for_pop, shm_queue_header< T >::ready_for_push, shm_queue< T >::seg, shm_ptr< T >::set(), shm_queue_header< T >::size, shm_queue_header< T >::tail, shm_queue_header< T >::tail_lock, and scoped_lock::wait().
Referenced by main().
Here is the call graph for this function:
void shm_queue< T >::lock_head | ( | ) | [inline] |
lock the head of the queue
Definition at line 187 of file shm_queue.h.
References shm_ptr< T >::get(), shm_queue_header< T >::head_lock, shm_queue< T >::seg, and shm_queue< T >::shm_header.
Here is the call graph for this function:
void shm_queue< T >::unlock_head | ( | ) | [inline] |
unlock the head of the queue
Definition at line 195 of file shm_queue.h.
References shm_ptr< T >::get(), shm_queue_header< T >::head_lock, shm_queue< T >::seg, and shm_queue< T >::shm_header.
Here is the call graph for this function:
void shm_queue< T >::lock_tail | ( | ) | [inline] |
lock the tail of the queue
Definition at line 203 of file shm_queue.h.
References shm_ptr< T >::get(), shm_queue< T >::seg, shm_queue< T >::shm_header, and shm_queue_header< T >::tail_lock.
Here is the call graph for this function:
void shm_queue< T >::unlock_tail | ( | ) | [inline] |
lock the tail of the queue
Definition at line 211 of file shm_queue.h.
References shm_ptr< T >::get(), shm_queue< T >::seg, shm_queue< T >::shm_header, and shm_queue_header< T >::tail_lock.
Here is the call graph for this function:
size_t shm_queue< T >::size | ( | ) | const [inline] |
get the size of the queue
Definition at line 219 of file shm_queue.h.
References shm_ptr< T >::get(), shm_queue< T >::seg, shm_queue< T >::shm_header, and shm_queue_header< T >::size.
Referenced by main().
Here is the call graph for this function:
size_t shm_queue< T >::MaxQueueSize [private] |
Definition at line 225 of file shm_queue.h.
shm_ptr< shm_queue_header<T> > shm_queue< T >::shm_header [private] |
Definition at line 227 of file shm_queue.h.
Referenced by shm_queue< T >::lock_head(), shm_queue< T >::lock_tail(), shm_queue< T >::shm_queue(), shm_queue< T >::size(), shm_queue< T >::unlock_head(), and shm_queue< T >::unlock_tail().
shm_allocator& shm_queue< T >::a [private] |
Definition at line 229 of file shm_queue.h.
Referenced by shm_queue< T >::operator delete(), shm_queue< T >::operator new(), shm_queue< T >::pop(), shm_queue< T >::push(), and shm_queue< T >::shm_queue().
const shm_segment& shm_queue< T >::seg [private] |
Definition at line 230 of file shm_queue.h.
Referenced by shm_queue< T >::lock_head(), shm_queue< T >::lock_tail(), shm_queue< T >::pop(), shm_queue< T >::push(), shm_queue< T >::shm_queue(), shm_queue< T >::size(), shm_queue< T >::unlock_head(), and shm_queue< T >::unlock_tail().
Project shmq hosted by | Documentation generated on Sat Sep 2 10:07:40 2006 for shmq by 1.4.6 |