version 1.2, 2006/07/11 18:39:28
|
version 1.3, 2006/08/09 21:12:42
|
|
|
| |
- NullLock - no locking at all. | - NullLock - no locking at all. |
- Mutex - non-recursive mutex. | - Mutex - non-recursive mutex. |
- RecursiveMutex - recursive mutex. |
- Mutex - recursive mutex. |
| |
Now we consider an example. So you want to create a list of Person | Now we consider an example. So you want to create a list of Person |
elements. First you must derive from the Linkable class as shown below. | elements. First you must derive from the Linkable class as shown below. |
|
|
\code | \code |
List<Person, NullLink>; // Do no synchronization. | List<Person, NullLink>; // Do no synchronization. |
List<Person, Mutex>; // Use Mutex class to synchronize. | List<Person, Mutex>; // Use Mutex class to synchronize. |
List<Person, RecursiveMutex>; // Use RecursiveMutex class to synchronize. |
List<Person, Mutex>; // Use Mutex class to synchronize. |
\endcode | \endcode |
| |
Finally, use the list. The following example adds three Person objects | Finally, use the list. The following example adds three Person objects |
to the back of the list and removes one from the front. | to the back of the list and removes one from the front. |
| |
\code | \code |
typedef List<Person, RecursiveMutex> PersonList; |
typedef List<Person, Mutex> PersonList; |
PersonList list; | PersonList list; |
| |
list.insert_back(new Person("John")); | list.insert_back(new Person("John")); |