Locking is a straightforward idea to protect a critical section. A critical section is a section of code that, at most, one thread can use at any time.
Dealing with Mutation: Locking
by Rainer Grimm
From the article:
Scoped locking is the idea of
RAII
applied to a mutex. Scoped locking is also known as synchronized block and guard. The key idea of this idiom is to bind the resource acquisition and release to an object’s lifetime. As the name suggests, the lifetime of the object is scoped. Scoped means that the C++ run time is responsible for object destruction and, therefore, for releasing the resource.The class
ScopedLock
implements Scoped Locking.
Add a Comment
Comments are closed.