Loading...
Searching...
No Matches
XrdXrootdFileLock1 Class Reference

`#include <XrdXrootdFileLock1.hh>`

Inheritance diagram for XrdXrootdFileLock1:
Collaboration diagram for XrdXrootdFileLock1:

## Public Member Functions

| XrdXrootdFileLock1 ()
| ~XrdXrootdFileLock1 ()
int | Lock (const char *path, char mode, bool force)
void | numLocks (const char *path, int &rcnt, int &wcnt)
int | Unlock (const char *path, char mode)

## Detailed Description

Definition at line 38 of file XrdXrootdFileLock1.hh.

## Constructor & Destructor Documentation

## XrdXrootdFileLock1()

XrdXrootdFileLock1::XrdXrootdFileLock1 | ( |  | ) |

inline

Definition at line 48 of file XrdXrootdFileLock1.hh.

{}

## ~XrdXrootdFileLock1()

XrdXrootdFileLock1::~XrdXrootdFileLock1 | ( |  | ) |

inline

Definition at line 49 of file XrdXrootdFileLock1.hh.

{} // This object is never destroyed!

## Member Function Documentation

## Lock()

int XrdXrootdFileLock1::Lock | ( | const char * | path,
|  | char | mode,
|  | bool | force )

virtual

Implements XrdXrootdFileLock.

Definition at line 80 of file XrdXrootdFileLock1.cc.

{
XrdXrootdLockFileLock locker(&LTMutex);
XrdXrootdFileLockInfo *lp;
// See if we already have a lock on this file
//
if ((lp = XrdXrootdLockTable.Find(path)))
{if (mode == 'r')
{if (lp->numWriters && !force)
return -lp->numWriters;
lp->numReaders++;
} else {
if ((lp->numReaders || lp->numWriters) && !force)
return (lp->numWriters ? -lp->numWriters : lp->numReaders);
lp->numWriters++;
}
return 0;
}
// Item does not exist, add it to the table
//
XrdXrootdLockTable.Add(path, new XrdXrootdFileLockInfo(mode));
return 0;
}
XrdXrootdLockTable
XrdOucHash< XrdXrootdFileLockInfo > XrdXrootdLockTable
Definition XrdXrootdFileLock1.cc:70
XrdXrootdFileLockInfo::numWriters
int numWriters
Definition XrdXrootdFileLock1.cc:45
XrdXrootdFileLockInfo::numReaders
int numReaders
Definition XrdXrootdFileLock1.cc:44

References XrdXrootdFileLockInfo::numReaders, XrdXrootdFileLockInfo::numWriters, and XrdXrootdLockTable.

## numLocks()

void XrdXrootdFileLock1::numLocks | ( | const char * | path,
|  | int & | rcnt,
|  | int & | wcnt )

virtual

Implements XrdXrootdFileLock.

Definition at line 112 of file XrdXrootdFileLock1.cc.

{
XrdXrootdLockFileLock locker(&LTMutex);
XrdXrootdFileLockInfo *lp;
if (!(lp = XrdXrootdLockTable.Find(path))) rcnt = wcnt = 0;
else {rcnt = lp->numReaders; wcnt = lp->numWriters;}
}

References XrdXrootdFileLockInfo::numReaders, XrdXrootdFileLockInfo::numWriters, and XrdXrootdLockTable.

## Unlock()

int XrdXrootdFileLock1::Unlock | ( | const char * | path,
|  | char | mode )

virtual

Implements XrdXrootdFileLock.

Definition at line 125 of file XrdXrootdFileLock1.cc.

{
XrdXrootdLockFileLock locker(&LTMutex);
XrdXrootdFileLockInfo *lp;
// See if we already have a lock on this file
//
if (!(lp = XrdXrootdLockTable.Find(path))) return 1;
// Adjust the lock information
//
if (mode == 'r')
{if (lp->numReaders == 0) return 1;
lp->numReaders--;
} else {
if (lp->numWriters == 0) return 1;
lp->numWriters--;
}
// Delete the entry if we no longer need it
//
if (lp->numReaders == 0 && lp->numWriters == 0)
XrdXrootdLockTable.Del(path);
return 0;
}

References XrdXrootdFileLockInfo::numReaders, XrdXrootdFileLockInfo::numWriters, and XrdXrootdLockTable.

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

- XrdXrootdFileLock1.hh
- XrdXrootdFileLock1.cc