pc_queue
|
 |
An os_pc_queue is a
first-in-first-out (FIFO) based producer consumer queue with a specified maximum
size (bounded buffer). Items can be inserted into the queue using the push()
method. If the queue is full, the calling thread blocks until the queue is not
full. Items can be removed from the queue in a FIFO order using the pop()
method. If the queue is empty, the calling thread blocks until the queue is not
empty.
The template arguments of the os_pc_queue
class are similar to the C++ standard library queue
container adapter class.
Declaration
#include <ospace/thread/pcqueue.h>
template< class T, class Container >
class os_pc_queue
Interface
Constructor
os_pc_queue(
size_type max_size )
Constructs a queue with a maximum size limit of max_size
and a default constructed object of type Container
as the internal buffer.
Constructor
os_pc_queue(
size_type max_size ,
const Container& container )
Constructs a priority queue with a maximum size
limit of max_size and a copy of container
as the internal buffer.
Destructor
~os_pc_queue()
Destroys the queue.
<
bool
operator<( const os_pc_queue< T, Container >& other
) const
Returns true if this
queue is lexicographically less than other .
==
bool
operator==( const os_pc_queue< T, Container >& other
) const
Returns true if this
queue and other are equivalent.
close
void close()
Closes the queue. No items will be allowed to be
pushed into the queue. Items will be allowed to be popped until the queue
becomes empty.
closed
bool closed()
const
Returns true if closed
for adding new items. All threads calling pop()
will not block.
empty
bool empty()
const
Returns true if the
queue contain no elements.
full
bool full()
const
Returns true if the
queue is full.
max_size
size_type
max_size() const
Returns the maximum number of elements the queue
can contain.
pop
value_type
pop()
Removes the item in the front of the queue (FIFO
order) and returns it. If the queue is empty, the calling thread blocks
until the queue is not empty. If this method is called after the queue is
closed, then an exception is thrown.
Throws: os_thread_toolkit_error
pop
void pop(
value_type& value )
Removes the item in the front of the queue (FIFO
order) and places a copy of it in value . If the
queue is empty, the calling thread blocks until the queue is not empty. If
this method is called after the queue is closed, then an exception is
thrown.
Throws: os_thread_toolkit_error
pop
bool pop(
value_type& value ,
long milliseconds )
Removes the item in the front of the queue (FIFO
order) and places a copy of it in value . If the
queue is empty, the calling thread blocks until the queue is not empty or
until milliseconds time expires. Returns true
if the value is filled with the popped value. If
this method is called after the queue is closed, then an exception is
thrown.
Throws: os_thread_toolkit_error
push
void push(
const value_type& value )
Inserts the item value
into the queue. If the queue is full, the calling thread blocks until the
queue is not full. If this method is called after the queue is closed, then
an exception is thrown.
Throws: os_thread_toolkit_error
push
bool push(
const value_type& value ,
long milliseconds )
Inserts the item value
into the queue. If the queue is full, the calling thread blocks until the
queue is not full or until milliseconds time
expires. Returns true if the value
is inserted. If this method is called after the queue is closed, then an
exception is thrown.
Throws: os_thread_toolkit_error
reopen
void reopen()
Reopens the queue for pushing and popping items.
size
size_type
size() const
Returns the number of elements that the queue
currently contains.
Copyright©1994-2026 Recursion
Software LLC
All Rights Reserved - For use by licensed users only.