xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdClient
XrdCpMthrQueue.hh
Go to the documentation of this file.
1
#ifndef XRDCPMTHRQ__HH
2
#define XRDCPMTHRQ__HH
3
/******************************************************************************/
4
/* */
5
/* X r d C p M t h r Q u e u e . h h */
6
/* */
7
/* Author: Fabrizio Furano (INFN Padova, 2004) */
8
/* */
9
/* This file is part of the XRootD software suite. */
10
/* */
11
/* XRootD is free software: you can redistribute it and/or modify it under */
12
/* the terms of the GNU Lesser General Public License as published by the */
13
/* Free Software Foundation, either version 3 of the License, or (at your */
14
/* option) any later version. */
15
/* */
16
/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
17
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
18
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
19
/* License for more details. */
20
/* */
21
/* You should have received a copy of the GNU Lesser General Public License */
22
/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
23
/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
24
/* */
25
/* The copyright holder's institutional names and contributor's names may not */
26
/* be used to endorse or promote products derived from this software without */
27
/* specific prior written permission of the institution or contributor. */
28
/******************************************************************************/
29
31
// //
32
// A thread safe queue to be used for multithreaded producers-consumers //
33
// //
35
36
#include "
XrdSys/XrdSysPthread.hh
"
37
#include "
XrdClient/XrdClientVector.hh
"
38
#include "
XrdSys/XrdSysSemWait.hh
"
39
#include "
XrdSys/XrdSysHeaders.hh
"
40
41
using namespace
std;
42
43
struct
XrdCpMessage
{
44
void
*
buf
;
45
long
long
offs
;
46
int
len
;
47
};
48
49
// The max allowed size for this queue
50
// If this value is reached, then the writer has to wait...
51
#define CPMTQ_BUFFSIZE 50000000
52
53
class
XrdCpMthrQueue
{
54
private
:
55
long
fTotSize
;
56
XrdClientVector<XrdCpMessage*>
fMsgQue
;
// queue for incoming messages
57
int
fMsgIter
;
// an iterator on it
58
int
fWrWait
;
// Write waiters
59
60
XrdSysRecMutex
fMutex
;
// mutex to protect data structures
61
62
XrdSysSemWait
fReadSem
;
// variable to make the reader wait
63
// until some data is available
64
XrdSysSemaphore
fWriteSem
;
// variable to make the writer wait
65
// if the queue is full
66
public
:
67
68
XrdCpMthrQueue
();
69
~XrdCpMthrQueue
() {}
70
71
int
PutBuffer(
void
*buf,
long
long
offs,
int
len);
72
int
GetBuffer(
void
**buf,
long
long
&offs,
int
&len);
73
int
GetLength
() {
return
fMsgQue.GetSize(); }
74
void
Clear();
75
};
76
#endif
Generated by
1.8.3.1