-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
768b872
commit 817ee97
Showing
8 changed files
with
1,106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* XrdClSharedQueue.hh | ||
* | ||
* Created on: Nov 22, 2016 | ||
* Author: simonm | ||
*/ | ||
|
||
#ifndef SRC_XRDCL_XRDCLSHAREDQUEUE_HH_ | ||
#define SRC_XRDCL_XRDCLSHAREDQUEUE_HH_ | ||
|
||
#include "XrdCl/XrdClSyncQueue.hh" | ||
|
||
namespace XrdCl | ||
{ | ||
|
||
template <typename Item> | ||
class SharedQueue : public SyncQueue<Item*> | ||
{ | ||
public: | ||
|
||
typedef void (*Dealloc_t)( Item* ); | ||
|
||
SharedQueue( Dealloc_t dealloc = 0 ) : Dealloc( dealloc ), pRefCount( 1 ) { } | ||
|
||
void Delete() | ||
{ | ||
XrdSysMutexHelper lck( this->pMutex ); | ||
--pRefCount; | ||
if( !pRefCount ) | ||
delete this; | ||
} | ||
|
||
SharedQueue* Self() | ||
{ | ||
XrdSysMutexHelper lck( this->pMutex ); | ||
++pRefCount; | ||
return this; | ||
} | ||
|
||
bool Empty() | ||
{ | ||
XrdSysMutexHelper lck( this->pMutex ); | ||
return this->pQueue.empty(); | ||
} | ||
|
||
private: | ||
|
||
~SharedQueue() | ||
{ | ||
if( !Dealloc ) return; | ||
|
||
while( this->pQueue.empty() ) | ||
{ | ||
Item *item = this->pQueue.front(); | ||
this->pQueue.pop(); | ||
Dealloc( item ); | ||
} | ||
} | ||
|
||
Dealloc_t Dealloc; | ||
|
||
// mutable XrdSysMutex pMutex; | ||
uint8_t pRefCount; | ||
}; | ||
|
||
} | ||
|
||
|
||
|
||
#endif /* SRC_XRDCL_XRDCLSHAREDQUEUE_HH_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.