Parametrizes synchronized mechanisms that protect a component's critical sections from concurrent access.
class LOCK { public: virtual void acquire() = 0; virtual void release() = 0; };
The implementation of the
template <class LOCK> class Guard { public: Guard( LOCK & lock ) : lock_( lock ), owner_( false ) { lock_->acquire(); owner_ = true; } ~Guard() { if ( owner_ ) lock_->release(); } private: LOCK * lock_; bool owner_; Guard( const Guard &); // disable copying void opertaor= ( const Guard & ); // disable assignment };
Marco Corvi - Page hosted by geocities.com.