IlsUnsafeMutex
Category
Thread utility class - API FOR ADVANCED USERS
Inheritance Path
IlsMTBase➥ IlsUnsafeMutex Description
A mutex is an object which provides mutually exclusive access to an object. A mutex is one of the basic building blocks of a multithreaded application.
An unsafe mutex is a mutex that offers the best possible performance but exhibits undefined behavior if not used correctly. Correct use of a mutex means that you do not lock a thread that is already locked by the same thread, and that you do not unlock a thread that is not locked or is locked by a thread that is not the current thread. If the user of the mutex cannot guarantee correct manipulation of the mutex, then a safe mutex should be used instead.
Libraries
Synopsis
class IlsUnsafeMutex : public IlsMTBase
{
public:
IlsUnsafeMutex(IlsBoolean trylock());
virtual ~IlsUnsafeMutex();
friend ostream&
operator<<(ostream&, const IlsUnsafeMutex&);
};
Member Functions
IlsBoolean lock();
This member function locks the mutex. It returns IlsFalse if the operation fails.
The thread library adds no additional overhead when locking an unsafe mutex when compared to the native library.
IlsBoolean trylock();
This member function tries to lock the mutex. Unlike lock, this member function will never block. If the mutex is already locked by another thread, then this function returns IlsFalse. It can also return IlsFalse if the lock operation fails for a system-dependent reason. The thread library causes no additional overhead when trying to lock an unsafe mutex as compared to the native library.
IlsBoolean unlock();
This member function is used to unlock the mutex. It returns IlsFalse if the operation fails. The thread library causes no additional overhead when locking an unsafe mutex as compared to the native library.
Operators
friend ostream& operator<<(ostream&, const IlsUnsafeMutex&);
This operator prints the name of the object to the output stream.
See Also
Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.