| Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits | 
| MutexLock< num_doors > Class Template ReferenceImplements a mutual exclusion lock using pthread mutex. More... 
 
Inheritance diagram for MutexLock< num_doors >:  Detailed Descriptiontemplate<unsigned int num_doors> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Public Member Functions | |
| MutexLock () | |
| constructor, gets a new semaphore from the semaphore manager | |
| ~MutexLock () | |
| destructor, releases semaphore back to semaphore manager | |
| void | lock (int id) | 
| blocks until lock is achieved. This is done efficiently using a SysV style semaphore | |
| bool | try_lock (int id) | 
| attempts to get a lock, returns true if it succeeds | |
| void | unlock () | 
| releases one recursive lock-level from whoever has the current lock | |
| void | releaseAll () | 
| completely unlocks, regardless of how many times a recursive lock has been obtained | |
| unsigned int | get_lock_level () const | 
| returns the lockcount | |
| int | owner () const | 
| returns the current owner's id | |
| Protected Member Functions | |
| virtual void | useResource (Resource::Data &) | 
| marks the resource as in use | |
| virtual void | releaseResource (Resource::Data &) | 
| releases the resource | |
| Protected Attributes | |
| unsigned int | owner_index | 
| holds the tekkotsu process id of the current lock owner | |
| Thread::Lock | thdLock | 
| all the actual implementation is handed off to the thread lock | |
| Friends | |
| class | MarkScope | 
constructor, gets a new semaphore from the semaphore manager
Definition at line 109 of file MutexLock.h.
destructor, releases semaphore back to semaphore manager
Definition at line 112 of file MutexLock.h.
| unsigned int MutexLock< num_doors >::get_lock_level | ( | ) | const | 
returns the lockcount
Definition at line 156 of file MutexLock.h.
Referenced by MessageQueue< MAX_UNREAD, MAX_RECEIVERS, MAX_SENDERS >::sendMessage().
| void MutexLock< num_doors >::lock | ( | int | id | ) | 
blocks until lock is achieved. This is done efficiently using a SysV style semaphore
You should pass some process-specific ID number as the input - just make sure no other process will be using the same value.
Definition at line 123 of file MutexLock.h.
Referenced by IPCEventTranslator::bufferRequest(), MotionManager::func_begin(), MotionManager::InitAccess(), MotionManager::lock(), MessageQueue< MAX_UNREAD, MAX_RECEIVERS, MAX_SENDERS >::sendMessage(), and MutexLock< MAX_ACCESS >::useResource().
| int MutexLock< num_doors >::owner | ( | ) | const | 
returns the current owner's id
Definition at line 159 of file MutexLock.h.
| void MutexLock< num_doors >::releaseAll | ( | ) | 
completely unlocks, regardless of how many times a recursive lock has been obtained
Definition at line 149 of file MutexLock.h.
Referenced by MessageQueue< MAX_UNREAD, MAX_RECEIVERS, MAX_SENDERS >::sendMessage().
| virtual void MutexLock< num_doors >::releaseResource | ( | Resource::Data & | d | ) |  [protected, virtual] | 
| bool MutexLock< num_doors >::try_lock | ( | int | id | ) | 
attempts to get a lock, returns true if it succeeds
You should pass some process-specific ID number as the input - just make sure no other process will be using the same value.
Definition at line 132 of file MutexLock.h.
Referenced by MotionManager::trylock().
| void MutexLock< num_doors >::unlock | ( | ) | 
releases one recursive lock-level from whoever has the current lock
Definition at line 140 of file MutexLock.h.
Referenced by IPCEventTranslator::bufferRequest(), MotionManager::func_end(), MotionManager::InitAccess(), IPCEventTranslator::post(), MutexLock< MAX_ACCESS >::releaseResource(), and MotionManager::unlock().
| virtual void MutexLock< num_doors >::useResource | ( | Resource::Data & | d | ) |  [protected, virtual] | 
| friend class MarkScope  [friend] | 
Definition at line 162 of file MutexLock.h.
| unsigned int MutexLock< num_doors >::owner_index  [protected] | 
holds the tekkotsu process id of the current lock owner
Definition at line 166 of file MutexLock.h.
Referenced by MutexLock< MAX_ACCESS >::lock(), MutexLock< MAX_ACCESS >::owner(), MutexLock< MAX_ACCESS >::releaseAll(), MutexLock< MAX_ACCESS >::try_lock(), MutexLock< MAX_ACCESS >::unlock(), and MutexLock< MAX_ACCESS >::~MutexLock().
| Thread::Lock MutexLock< num_doors >::thdLock  [protected] | 
all the actual implementation is handed off to the thread lock
Definition at line 167 of file MutexLock.h.
Referenced by MutexLock< MAX_ACCESS >::get_lock_level(), MutexLock< MAX_ACCESS >::lock(), MutexLock< MAX_ACCESS >::releaseAll(), MutexLock< MAX_ACCESS >::try_lock(), MutexLock< MAX_ACCESS >::unlock(), and MutexLock< MAX_ACCESS >::~MutexLock().
| Tekkotsu v5.1CVS | Generated Mon May 9 04:59:13 2016 by Doxygen 1.6.3 |