Base Framework
Public Member Functions | List of all members
ExclusiveSynchronize< GUARD > Class Template Reference

Exclusive synchronization. More...

#include <base/concurrency/ExclusiveSynchronize.h>

Public Member Functions

 ExclusiveSynchronize (const Guard &_guard)
 
 ~ExclusiveSynchronize ()
 

Detailed Description

template<class GUARD>
class ExclusiveSynchronize< GUARD >

Exclusive synchronization.

This class is used to synchronize executing contexts exclusively with a guard object of your choice.

class MyResource : public Object {
private:
public:
void myFirstMethod() const {
SynchronizeShared<ReadWriteLock> synchronizeShared(guard);
// do something as long as it doesn't modify the object
if (earlyReturn) {
return; // no need to explicitly release guard
}
bassert(!somethingWentWrong, MyResourceException()); // no need to explicitly release guard
}
void mySecondMethod() {
ExclusiveExclusive<ReadWriteLock> exclusiveShared(guard);
// do modification of object
if (earlyReturn) {
return; // no need to explicitly release guard
}
bassert(!somethingWentWrong, MyResourceException()); // no need to explicitly release guard
}
};
See also
SharedSynchronize
Version
1.0
Examples
testsuite/Thread.cpp.

Constructor & Destructor Documentation

◆ ExclusiveSynchronize()

template<class GUARD >
ExclusiveSynchronize< GUARD >::ExclusiveSynchronize ( const Guard &  _guard)
inlineexplicit

Initializes the synchronization object.

Parameters
guardThe synchronize able object to be synchronized.

◆ ~ExclusiveSynchronize()

template<class GUARD >
ExclusiveSynchronize< GUARD >::~ExclusiveSynchronize ( )
inline

Releases the lock if not already released and destroys the synchronization object.

Object
Object.
Definition: Object.h:28
ReadWriteLock
Read-write synchronization object.
Definition: ReadWriteLock.h:35