xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdSys
XrdSysXSLock.hh
Go to the documentation of this file.
1
#ifndef __SYS_XSLOCK_HH__
2
#define __SYS_XSLOCK_HH__
3
/******************************************************************************/
4
/* */
5
/* X r d S y s X S L o c k . h h */
6
/* */
7
/* (c) 2003 by the Board of Trustees of the Leland Stanford, Jr., University */
8
/* All Rights Reserved */
9
/* Produced by Andrew Hanushevsky for Stanford University under contract */
10
/* DE-AC03-76-SFO0515 with the Department of Energy */
11
/******************************************************************************/
12
13
// $Id$
14
15
#include <errno.h>
16
#include "
XrdSys/XrdSysPthread.hh
"
17
18
// These are valid usage options
19
//
20
enum
XrdSysXS_Type
{
xs_None
= 0,
xs_Shared
= 1,
xs_Exclusive
= 2};
21
22
// This class implements the shared lock. Any number of readers are allowed
23
// by requesting a shared lock. Only one exclusive writer is allowed by
24
// requesting an exclusive lock. Up/downgrading is not supported.
25
//
26
class
XrdSysXSLock
27
{
28
public
:
29
30
void
Lock
(
const
XrdSysXS_Type
usage);
31
32
void
UnLock
(
const
XrdSysXS_Type
usage=
xs_None
);
33
34
XrdSysXSLock
() :
cur_usage
(
xs_None
),
cur_count
(0),
exc_wait
(0),
35
shr_wait
(0),
toggle
(0),
WantShr
(0),
WantExc
(0) {}
36
~XrdSysXSLock
();
37
38
private
:
39
40
XrdSysXS_Type
cur_usage
;
41
int
cur_count
;
42
int
exc_wait
;
43
int
shr_wait
;
44
int
toggle
;
45
46
XrdSysMutex
LockContext
;
47
XrdSysSemaphore
WantShr
;
48
XrdSysSemaphore
WantExc
;
49
};
50
#endif
Generated by
1.8.1.2