The Pedigree Project  0.1
Public Member Functions | Private Member Functions | Private Attributes | List of all members
LockedFile Class Reference

#include <LockedFile.h>

+ Collaboration diagram for LockedFile:

Public Member Functions

 LockedFile (File *pFile)
 
 LockedFile (LockedFile &c)
 
LockedFileoperator= (const LockedFile &c)
 
bool lock (bool bBlock=false)
 
void unlock ()
 
FilegetFile ()
 
size_t getLocker ()
 

Private Member Functions

 LockedFile ()
 

Private Attributes

Filem_File
 
bool m_bLocked
 
size_t m_LockerPid
 
Mutex m_Lock
 

Detailed Description

LockedFile is a wrapper around a standard File with the ability to lock access to it. Locked access is in the form of a Mutex that allows only one thread exclusive access to the file.

Definition at line 32 of file LockedFile.h.

Constructor & Destructor Documentation

LockedFile::LockedFile ( File pFile)

Standard wrapper constructor

Definition at line 28 of file LockedFile.cc.

LockedFile::LockedFile ( LockedFile c)

Copy constructor

Definition at line 36 of file LockedFile.cc.

References Semaphore::acquire(), m_bLocked, m_File, m_Lock, and m_LockerPid.

LockedFile::LockedFile ( )
private

Default constructor, not to be used

Member Function Documentation

File * LockedFile::getFile ( )

To enforce mandatory locking, use this function to obtain a File to work with. If the file is locked and you don't own the lock, you'll get a NULL File. Otherwise you'll get the wrapped File ready for I/O.

Definition at line 87 of file LockedFile.cc.

References Processor::information(), m_bLocked, m_File, and m_LockerPid.

size_t LockedFile::getLocker ( )

Who's locking the file?

Definition at line 101 of file LockedFile.cc.

References m_bLocked, and m_LockerPid.

bool LockedFile::lock ( bool  bBlock = false)

Attempts to obtain the lock (exclusively)

Definition at line 55 of file LockedFile.cc.

References Semaphore::acquire(), Processor::information(), m_bLocked, m_Lock, m_LockerPid, and Semaphore::tryAcquire().

LockedFile& LockedFile::operator= ( const LockedFile c)

Operator =

Todo:
Write me!
void LockedFile::unlock ( )

Releases the lock

Definition at line 76 of file LockedFile.cc.

References m_bLocked, m_Lock, and Semaphore::release().

Referenced by FileDescriptor::~FileDescriptor().

+ Here is the caller graph for this function:

Member Data Documentation

bool LockedFile::m_bLocked
private

Is this file locked?

Definition at line 70 of file LockedFile.h.

Referenced by getFile(), getLocker(), lock(), LockedFile(), and unlock().

File* LockedFile::m_File
private

Is a range locked? The file that we're wrapping

Definition at line 67 of file LockedFile.h.

Referenced by getFile(), and LockedFile().

Mutex LockedFile::m_Lock
private

Our lock

Definition at line 77 of file LockedFile.h.

Referenced by lock(), LockedFile(), and unlock().

size_t LockedFile::m_LockerPid
private

Locker PID

Definition at line 73 of file LockedFile.h.

Referenced by getFile(), getLocker(), lock(), and LockedFile().


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