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

Shared synchronization. More...

#include <base/concurrency/SharedSynchronize.h>

Public Member Functions

 SharedSynchronize (const Guard &_guard)
 
 ~SharedSynchronize ()
 

Detailed Description

template<class GUARD>
class SharedSynchronize< GUARD >

Shared synchronization.

This class is used to synchronize executing contexts (shared) with a guard object of your choice. Some guard classes may implement the shared locks using exclusive locks.

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
ExclusiveSynchronize
Version
1.0

Constructor & Destructor Documentation

◆ SharedSynchronize()

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

Initializes the synchronization object.

Parameters
guardThe synchronize able object to be synchronized.

◆ ~SharedSynchronize()

template<class GUARD >
SharedSynchronize< GUARD >::~SharedSynchronize ( )
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