/src/libtomahawk/thirdparty/kdsingleapplicationguard/kdsharedmemorylocker.cpp
http://github.com/tomahawk-player/tomahawk · C++ · 40 lines · 18 code · 8 blank · 14 comment · 1 complexity · a29347d5841b320fbd47b91270fa0a94 MD5 · raw file
- #include "kdsharedmemorylocker.h"
- #if QT_VERSION >= 0x040400 || defined( DOXYGEN_RUN )
- #include <QSharedMemory>
- using namespace kdtools;
- /*!
- \class KDSharedMemoryLocker
- \ingroup raii core
- \brief Exception-safe and convenient wrapper around QSharedMemory::lock()
- */
- /**
- * Constructor. Locks the shared memory segment \a mem.
- * If another process has locking the segment, this constructor blocks
- * until the lock is released. The memory segments needs to be properly created or attached.
- */
- KDSharedMemoryLocker::KDSharedMemoryLocker( QSharedMemory* mem )
- : mem( mem )
- {
- mem->lock();
- }
- /**
- * Destructor. Unlocks the shared memory segment associated with this
- * KDSharedMemoryLocker.
- */
- KDSharedMemoryLocker::~KDSharedMemoryLocker()
- {
- mem->unlock();
- }
- #ifdef KDAB_EVAL
- #include KDAB_EVAL
- static const EvalDialogChecker evalChecker( "KD Tools", false );
- #endif
- #endif