xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdClient
XrdCpMthrQueue.hh
Go to the documentation of this file.
1
2
// //
3
// XrdCpMthrQueue //
4
// //
5
// Author: Fabrizio Furano (INFN Padova, 2004) //
6
// //
7
// A thread safe queue to be used for multithreaded producers-consumers //
8
// //
10
11
#include "
XrdSys/XrdSysPthread.hh
"
12
#include "
XrdClient/XrdClientVector.hh
"
13
#include "
XrdSys/XrdSysSemWait.hh
"
14
#include "
XrdSys/XrdSysHeaders.hh
"
15
16
using namespace
std;
17
18
struct
XrdCpMessage
{
19
void
*
buf
;
20
long
long
offs
;
21
int
len
;
22
};
23
24
// The max allowed size for this queue
25
// If this value is reached, then the writer has to wait...
26
#define CPMTQ_BUFFSIZE 50000000
27
28
class
XrdCpMthrQueue
{
29
private
:
30
long
fTotSize
;
31
XrdClientVector<XrdCpMessage*>
fMsgQue
;
// queue for incoming messages
32
int
fMsgIter
;
// an iterator on it
33
int
fWrWait
;
// Write waiters
34
35
XrdSysRecMutex
fMutex
;
// mutex to protect data structures
36
37
XrdSysSemWait
fReadSem
;
// variable to make the reader wait
38
// until some data is available
39
XrdSysSemaphore
fWriteSem
;
// variable to make the writer wait
40
// if the queue is full
41
public
:
42
43
XrdCpMthrQueue
();
44
~XrdCpMthrQueue
() {}
45
46
int
PutBuffer(
void
*buf,
long
long
offs,
int
len);
47
int
GetBuffer(
void
**buf,
long
long
&offs,
int
&len);
48
int
GetLength
() {
return
fMsgQue.GetSize(); }
49
void
Clear();
50
};
51
Generated by
1.8.1.2