XRootD
Loading...
Searching...
No Matches
XrdCl::SyncQueue< Item > Class Template Reference

A synchronized queue. More...

#include <XrdClSyncQueue.hh>

Collaboration diagram for XrdCl::SyncQueue< Item >:

Public Member Functions

 SyncQueue ()
 Constructor.
 ~SyncQueue ()
 Destructor.
void Clear ()
 Clear the queue.
Item Get ()
 Get the item from the front of the queue.
bool IsEmpty ()
 Check if the queue is empty.
void Put (const Item &item)
 Put the item in the queue.

Protected Attributes

XrdSysMutex pMutex
std::queue< Item > pQueue
XrdSysSemaphorepSem

Detailed Description

template<typename Item>
class XrdCl::SyncQueue< Item >

A synchronized queue.

Definition at line 32 of file XrdClSyncQueue.hh.

Constructor & Destructor Documentation

◆ SyncQueue()

template<typename Item>
XrdCl::SyncQueue< Item >::SyncQueue ( )
inline

Constructor.

Definition at line 38 of file XrdClSyncQueue.hh.

39 {
40 pSem = new XrdSysSemaphore(0);
41 };
A synchronized queue.
XrdSysSemaphore * pSem

References pSem.

◆ ~SyncQueue()

template<typename Item>
XrdCl::SyncQueue< Item >::~SyncQueue ( )
inline

Destructor.

Definition at line 46 of file XrdClSyncQueue.hh.

47 {
48 delete pSem;
49 }

References pSem.

Member Function Documentation

◆ Clear()

template<typename Item>
void XrdCl::SyncQueue< Item >::Clear ( )
inline

Clear the queue.

Definition at line 81 of file XrdClSyncQueue.hh.

82 {
84 while( !pQueue.empty() )
85 pQueue.pop();
86 delete pSem;
87 pSem = new XrdSysSemaphore(0);
88 }
std::queue< Item > pQueue

References pMutex, pQueue, and pSem.

◆ Get()

template<typename Item>
Item XrdCl::SyncQueue< Item >::Get ( )
inline

Get the item from the front of the queue.

Definition at line 64 of file XrdClSyncQueue.hh.

65 {
66 pSem->Wait();
68
69 // this is not possible, so when it happens we commit a suicide
70 if( pQueue.empty() )
71 abort();
72
73 Item i = pQueue.front();
74 pQueue.pop();
75 return i;
76 }

References pMutex, pQueue, and pSem.

◆ IsEmpty()

template<typename Item>
bool XrdCl::SyncQueue< Item >::IsEmpty ( )
inline

Check if the queue is empty.

Definition at line 93 of file XrdClSyncQueue.hh.

94 {
96 return pQueue.empty();
97 }

References pMutex, and pQueue.

◆ Put()

template<typename Item>
void XrdCl::SyncQueue< Item >::Put ( const Item & item)
inline

Put the item in the queue.

Definition at line 54 of file XrdClSyncQueue.hh.

55 {
57 pQueue.push( item );
58 pSem->Post();
59 }

References pMutex, pQueue, and pSem.

Member Data Documentation

◆ pMutex

template<typename Item>
XrdSysMutex XrdCl::SyncQueue< Item >::pMutex
protected

Definition at line 101 of file XrdClSyncQueue.hh.

Referenced by Clear(), Get(), IsEmpty(), and Put().

◆ pQueue

template<typename Item>
std::queue<Item> XrdCl::SyncQueue< Item >::pQueue
protected

Definition at line 100 of file XrdClSyncQueue.hh.

Referenced by Clear(), Get(), IsEmpty(), and Put().

◆ pSem

template<typename Item>
XrdSysSemaphore* XrdCl::SyncQueue< Item >::pSem
protected

Definition at line 102 of file XrdClSyncQueue.hh.

Referenced by SyncQueue(), ~SyncQueue(), Clear(), Get(), and Put().


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