Server
API Reference Guide
Product Documentation:

Rogue Wave Server
Documentation Home
List of all members | Public Member Functions | Friends
IlsUnsafeMutex Class Reference

API FOR ADVANCED USERS – 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. More...

#include <ilserver/ilthread.h>

Inheritance diagram for IlsUnsafeMutex:
IlsMTBase

Public Member Functions

IlsBoolean lock ()
 This member function locks the mutex. More...
 
IlsBoolean trylock ()
 This member function tries to lock the mutex. More...
 
IlsBoolean unlock ()
 This member function is used to unlock the mutex. More...
 
- Public Member Functions inherited from IlsMTBase
virtual ~IlsMTBase ()
 This is the public virtual destructor for this class.
 
virtual IlsThreadObjectName getName () const
 This member function returns the name of an object. More...
 

Friends

class IlsCond
 
ostream & operator<< (ostream &, const IlsUnsafeMutex &)
 This operator prints the name of the object to the output stream. More...
 

Detailed Description

API FOR ADVANCED USERS – 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.

Library: server
and mvcomp

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 (IlsSafeMutex) should be used instead.

See also
IlsSafeMutex, IlsThread.

Member Function Documentation

◆ lock()

IlsBoolean IlsUnsafeMutex::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.

◆ trylock()

IlsBoolean IlsUnsafeMutex::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.

◆ unlock()

IlsBoolean IlsUnsafeMutex::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.

Friends And Related Function Documentation

◆ operator<<

ostream& operator<< ( ostream &  ,
const IlsUnsafeMutex  
)
friend

This operator prints the name of the object to the output stream.

This uses the method getName() to get the name of the mutex. If the method getName() returns 0 then it uses a platform dependent value.