Loading...
Searching...
No Matches
XrdEc::sync_queue< Element > Struct Template Reference

`#include <XrdEcUtilities.hh>`

Collaboration diagram for XrdEc::sync_queue< Element >:

## Classes

struct | wait_interrupted

## Public Member Functions

| sync_queue ()
Element | dequeue ()
bool | dequeue (Element &e)
bool | empty ()
void | enqueue (Element &&element)
void | interrupt ()

## Detailed Description

template<typename Element>
struct XrdEc::sync_queue< Element >

Definition at line 168 of file XrdEcUtilities.hh.

## Class Documentation

## XrdEc::sync_queue::wait_interrupted

struct XrdEc::sync_queue::wait_interrupted

template<typename Element>
struct XrdEc::sync_queue< Element >::wait_interrupted

Definition at line 173 of file XrdEcUtilities.hh.

Collaboration diagram for XrdEc::sync_queue< Element >::wait_interrupted:

## Constructor & Destructor Documentation

## sync_queue()

template<typename Element>

XrdEc::sync_queue< Element >::sync_queue | ( |  | ) |

inline

Definition at line 178 of file XrdEcUtilities.hh.

: interrupted( false )
{
}

## Member Function Documentation

## dequeue() [1/2]

template<typename Element>

Element XrdEc::sync_queue< Element >::dequeue | ( |  | ) |

inline

Definition at line 196 of file XrdEcUtilities.hh.

{
std::unique_lock<std::mutex> lck( mtx );
while( elements.empty() )
{
cv.wait( lck );
if( interrupted ) throw wait_interrupted();
}
Element element = std::move( elements.front() );
elements.pop();
return element;
}
XrdEc::sync_queue
Definition XrdEcUtilities.hh:169
XrdEc::sync_queue::wait_interrupted
Definition XrdEcUtilities.hh:173

## dequeue() [2/2]

template<typename Element>

bool XrdEc::sync_queue< Element >::dequeue | ( | Element & | e | ) |

inline

Definition at line 213 of file XrdEcUtilities.hh.

{
std::unique_lock<std::mutex> lck( mtx );
if( elements.empty() ) return false;
e = std::move( elements.front() );
elements.pop();
return true;
}

## empty()

template<typename Element>

bool XrdEc::sync_queue< Element >::empty | ( |  | ) |

inline

Definition at line 225 of file XrdEcUtilities.hh.

{
std::unique_lock<std::mutex> lck( mtx );
return elements.empty();
}

## enqueue()

template<typename Element>

void XrdEc::sync_queue< Element >::enqueue | ( | Element && | element | ) |

inline

Definition at line 185 of file XrdEcUtilities.hh.

{
std::unique_lock<std::mutex> lck( mtx );
elements.push( std::move( element ) );
cv.notify_all();
}

## interrupt()

template<typename Element>

void XrdEc::sync_queue< Element >::interrupt | ( |  | ) |

inline

Definition at line 234 of file XrdEcUtilities.hh.

{
interrupted = true;
cv.notify_all();
}

The documentation for this struct was generated from the following file:

- XrdEcUtilities.hh