~ubuntu-branches/ubuntu/trusty/tomahawk/trusty-proposed

« back to all changes in this revision

Viewing changes to src/libtomahawk/thirdparty/kdsingleapplicationguard/kdsharedmemorylocker.cpp

  • Committer: Package Import Robot
  • Author(s): Harald Sitter
  • Date: 2013-03-07 21:50:13 UTC
  • Revision ID: package-import@ubuntu.com-20130307215013-6gdjkdds7i9uenvs
Tags: upstream-0.6.0+dfsg
ImportĀ upstreamĀ versionĀ 0.6.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "kdsharedmemorylocker.h"
 
2
 
 
3
#if QT_VERSION >= 0x040400 || defined( DOXYGEN_RUN )
 
4
 
 
5
#include <QSharedMemory>
 
6
 
 
7
using namespace kdtools;
 
8
 
 
9
/*!
 
10
  \class KDSharedMemoryLocker
 
11
  \ingroup raii core
 
12
  \brief Exception-safe and convenient wrapper around QSharedMemory::lock()
 
13
*/
 
14
 
 
15
/**
 
16
 * Constructor. Locks the shared memory segment \a mem.
 
17
 * If another process has locking the segment, this constructor blocks
 
18
 * until the lock is released. The memory segments needs to be properly created or attached.
 
19
 */
 
20
KDSharedMemoryLocker::KDSharedMemoryLocker( QSharedMemory* mem )
 
21
    : mem( mem )
 
22
{
 
23
    mem->lock();
 
24
}
 
25
 
 
26
/**
 
27
 * Destructor. Unlocks the shared memory segment associated with this
 
28
 * KDSharedMemoryLocker.
 
29
 */
 
30
KDSharedMemoryLocker::~KDSharedMemoryLocker()
 
31
{
 
32
    mem->unlock();
 
33
}
 
34
 
 
35
#ifdef KDAB_EVAL
 
36
#include KDAB_EVAL
 
37
static const EvalDialogChecker evalChecker( "KD Tools", false );
 
38
#endif
 
39
 
 
40
#endif