2012-02-20 21:47:14 +00:00
|
|
|
/* This file is (c) 2008-2012 Konstantin Isakov <ikm@goldendict.org>
|
2009-03-26 19:00:08 +00:00
|
|
|
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
|
|
|
|
|
|
|
#ifndef __MUTEX_HH_INCLUDED__
|
|
|
|
#define __MUTEX_HH_INCLUDED__
|
|
|
|
|
2022-03-30 14:08:58 +00:00
|
|
|
#include <QRecursiveMutex>
|
2009-03-26 19:00:08 +00:00
|
|
|
|
|
|
|
/// This provides a mutex class. As you can see, it's just a Qt one, but it
|
|
|
|
/// does provide the Lock class which doesn't seem to exist in Qt, and it does
|
|
|
|
/// provide some abstraction for dictionaries in case they are to be ported
|
|
|
|
/// away from Qt.
|
2022-03-30 14:08:58 +00:00
|
|
|
class Mutex: public QRecursiveMutex
|
2009-03-26 19:00:08 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-03-30 14:08:58 +00:00
|
|
|
Mutex() : QRecursiveMutex( )
|
2021-11-12 18:26:46 +00:00
|
|
|
{}
|
|
|
|
~Mutex()
|
|
|
|
{}
|
2009-03-26 19:00:08 +00:00
|
|
|
|
|
|
|
/// Locks the given mutex on construction and unlocks on destruction
|
|
|
|
class Lock
|
|
|
|
{
|
|
|
|
Mutex & m;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
Lock( Mutex & );
|
|
|
|
~Lock();
|
|
|
|
|
|
|
|
private:
|
|
|
|
Lock( Lock const & );
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|