XRootD
XrdCl::SyncQueue< Item > Class Template Reference

A synchronized queue. More...

#include <XrdClSyncQueue.hh>

+ Collaboration diagram for XrdCl::SyncQueue< Item >:

Public Member Functions

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

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  };
XrdSysSemaphore * pSem

References XrdCl::SyncQueue< Item >::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 XrdCl::SyncQueue< Item >::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  {
83  XrdSysMutexHelper scopedLock( pMutex );
84  while( !pQueue.empty() )
85  pQueue.pop();
86  delete pSem;
87  pSem = new XrdSysSemaphore(0);
88  }
XrdSysMutex pMutex
std::queue< Item > pQueue

References XrdCl::SyncQueue< Item >::pMutex, XrdCl::SyncQueue< Item >::pQueue, and XrdCl::SyncQueue< Item >::pSem.

Referenced by XrdCl::JobManager::Finalize().

+ Here is the caller graph for this function:

◆ 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();
67  XrdSysMutexHelper scopedLock( pMutex );
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 XrdCl::SyncQueue< Item >::pMutex, XrdCl::SyncQueue< Item >::pQueue, XrdCl::SyncQueue< Item >::pSem, and XrdSysSemaphore::Wait().

Referenced by XrdCl::JobManager::RunJobs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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  {
95  XrdSysMutexHelper scopedLock( pMutex );
96  return pQueue.empty();
97  }

References XrdCl::SyncQueue< Item >::pMutex, and XrdCl::SyncQueue< Item >::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  {
56  XrdSysMutexHelper scopedLock( pMutex );
57  pQueue.push( item );
58  pSem->Post();
59  }

References XrdCl::SyncQueue< Item >::pMutex, XrdSysSemaphore::Post(), XrdCl::SyncQueue< Item >::pQueue, and XrdCl::SyncQueue< Item >::pSem.

Referenced by XrdCl::JobManager::QueueJob().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ pMutex

◆ pQueue

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

◆ pSem


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