PikeAero::CMutexLock Class Reference

#include <cmutexlock.h>

Collaboration diagram for PikeAero::CMutexLock:

Collaboration graph
[legend]

Public Member Functions

 CMutexLock (CMutex *mutex=NULL)
void lock (CMutex *mutex=NULL)
bool tryLock (CMutex *mutex=NULL)
void unlock (CMutex *mutex=NULL)
 ~CMutexLock ()

Private Attributes

CMutexmMutex

Detailed Description

Implements a mutually exclusive (MUTEX) locking function.
Author:
Michael Sharkey <mike@pikeaero.com>

Definition at line 32 of file cmutexlock.h.


Constructor & Destructor Documentation

PikeAero::CMutexLock::CMutexLock ( CMutex mutex = NULL  ) 

Definition at line 27 of file cmutexlock.cpp.

References lock(), and mMutex.

00028 : mMutex(mutex)
00029 {
00030     if ( mMutex != NULL )
00031     {
00032         lock();
00033     }
00034 }

Here is the call graph for this function:

PikeAero::CMutexLock::~CMutexLock (  ) 

Definition at line 36 of file cmutexlock.cpp.

References unlock().

00037 {
00038     unlock();
00039 }

Here is the call graph for this function:


Member Function Documentation

void PikeAero::CMutexLock::lock ( CMutex mutex = NULL  ) 

Definition at line 41 of file cmutexlock.cpp.

References disableInterrupts, interruptsEnabled, PikeAero::CMutex::mLocked, mMutex, setInterrupts, and PikeAero::CTaskScheduler::yield().

Referenced by CMutexLock().

00042 {
00043     if ( mutex != NULL ) mMutex = mutex;
00044     if ( mMutex != NULL )
00045     {
00046         bool gotLock=false;
00047         while ( !gotLock )
00048         {
00049             CTaskScheduler::yield();
00050             bool irqState = interruptsEnabled();
00051             disableInterrupts();
00052             if ( !mMutex->mLocked )
00053             {
00054                 mMutex->mLocked = true;
00055                 gotLock=true;
00056             }
00057             setInterrupts(irqState);
00058         }
00059     }
00060 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool PikeAero::CMutexLock::tryLock ( CMutex mutex = NULL  ) 

Definition at line 71 of file cmutexlock.cpp.

References PikeAero::CMutex::mLocked, and mMutex.

00072 {
00073     if ( mutex != NULL ) mMutex = mutex;
00074     if ( mMutex != NULL )
00075     {
00076         return mMutex->mLocked;
00077     }
00078     return false;
00079 }

void PikeAero::CMutexLock::unlock ( CMutex mutex = NULL  ) 

Definition at line 62 of file cmutexlock.cpp.

References PikeAero::CMutex::mLocked, and mMutex.

Referenced by ~CMutexLock().

00063 {
00064     if ( mutex != NULL ) mMutex = mutex;
00065     if ( mMutex != NULL )
00066     {
00067         mMutex->mLocked = false;
00068     }
00069 }

Here is the caller graph for this function:


Field Documentation

Definition at line 43 of file cmutexlock.h.

Referenced by CMutexLock(), lock(), tryLock(), and unlock().


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

Generated on Sun Oct 25 14:00:11 2009 for stingray3 by  doxygen 1.5.8