Informació general
Exemples
Pantallas
Comparacions
Aplicacions
Descarregar
Documentation
"El Mercat"
Estat i Pla de treball
Preguntes més freqüents
Autors i Llicència
Fòrums
Finançament de l'U++
Cerca en aquesta web
Llengua
català











SourceForge.net Logo



Aquesta pàgina no s'ha traduït encara. Vols traduirla?

 

Mutex

 

class Mutex : private NoCopy

This well know synchronization primitive is usually used to serialize access to shared data or other shared resources. Only single thread can execute the code between calls to Enter and Leave. If any other thread attempts to Enter the protected section while other thread is performing it, it is blocked until performing thread indicates leaving the section by invoking Leave.

 

 

Public Method List

 

void Enter()

Enter the protected region of code. Only single thread can enter the region, other threads block until Leave is invoked.

 


 

bool TryEnter()

Attempts to enter the protected region of code. If other thread owns the region, returns false, otherwise gains the ownership of Mutex and returns true. Never blocks.

 


 

void Leave()

Leave the protected region of code. Only the same thread that called Enter can invoke Leave.

 

 

 

 

StaticMutex

 

class StaticMutex

Variant of Mutex that can be used as static or global variable without the need of initialization  - it has no constructor and correctly performs the first initialization when any of methods is called. That avoids problems with initialization order or multithreaded initialization issues.

 

 

Public Method List

 

Mutex& Get()

operator Mutex&()

Returns the initialized instance of Mutex.

 


 

bool TryEnter()

void Enter()

void Leave()

Calls respective methods of Mutex instance.

 

 

 

 

Mutex::Lock

 

class Mutex::Lock

This nested class automates calls to Mutex::Enter / Mutex::Leave for block of code using C++ constructor / destructor rules. Using operator StaticMutex::Mutex, it can be used with StaticMutex as well.

 

 

Constructor / Destructor detail

 

Lock(Mutex& s)

Performs s.Enter().

 


 

~Lock()

Performs s.Enter() where s is the constructor parameter.

 

 

Aquesta pàgina també està en english. Vols col.laborar?