Template Class ipc_queue

Class Documentation

template<class T>
class ipc_queue

Interprocess synchronized queue (like multithread::mt_queue, but for processes).

Public Types

typedef bip::allocator<T, bip::managed_shared_memory::segment_manager> allocator_type

Public Functions

inline explicit ipc_queue(allocator_type alloc)
inline void clear(void)

Empty the queue.

inline bool is_empty() const

Determine if the queue is current empty or not. This function performs no locking, and even if it did, the result would be immediately out of date, so don’t depend on this value among multiple processes without additional synchronization.

Returns:

TRUE if the condition is met, FALSE otherwise.

inline T pop(void)

Get the front element in the queue.

Returns:

The front element.

inline bool pop_timed_wait(T *const element, int to_sec)

Get the front element in the queue, waiting a set # of seconds before timing out if the queue is currently empty.

Parameters:
  • element – To be filled with the front item in the queue.

  • to_sec – # of seconds for timeout.

Returns:

TRUE if an item was removed from the queue, FALSE otherwise.

inline bool pop_try(T *const element)

Get the front element in the queue if it exists.

Parameters:

element – To be filled with the front item in the queue if it exists.

Returns:

TRUE if the front element was removed, FALSE otherwise.

inline void pop_wait(T *const element)

Get the front element in the queue, waiting indefinitely if the queue is currently empty.

Parameters:

element – To be filled with the front item in the queue.

inline void push(T element)

Push an element onto the queue, notifying at most 1 process waiting on the queue.

Parameters:

element – The element to add.

inline size_t size() const

Get the current # of elements in the queue. This function performs no locking, and even if it did, the result would be immediately out of date, so don’t depend on this value among multiple processes without additional synchronization.

Returns:

The current # elements in the queue.