]> git.pld-linux.org Git - packages/akonadi.git/blame - 0015-Use-QMutexLocker-instead-of-manual-lock-unlock-calls.patch
boost rebuild
[packages/akonadi.git] / 0015-Use-QMutexLocker-instead-of-manual-lock-unlock-calls.patch
CommitLineData
8a8f9fb3
AM
1From f5a0e3f1f4787b6a48880e42463ae38dce336a8f Mon Sep 17 00:00:00 2001
2From: Milian Wolff <mail@milianw.de>
3Date: Mon, 1 Dec 2014 11:36:31 +0100
4Subject: [PATCH 15/30] Use QMutexLocker instead of manual lock/unlock calls.
5
6Just a minor cleanup patch, no change of behavior.
7---
8 server/src/storage/entities-source.xsl | 17 +++++------------
9 server/src/storage/entities.xsl | 4 +---
10 2 files changed, 6 insertions(+), 15 deletions(-)
11
12diff --git a/server/src/storage/entities-source.xsl b/server/src/storage/entities-source.xsl
13index 7090c31..05a8cb1 100644
14--- a/server/src/storage/entities-source.xsl
15+++ b/server/src/storage/entities-source.xsl
16@@ -125,14 +125,13 @@ void <xsl:value-of select="$className"/>::Private::addToCache( const <xsl:value-
17 {
18 Q_ASSERT( cacheEnabled );
19 Q_UNUSED( entry ); <!-- in case the table has neither an id nor name column -->
20- cacheMutex.lock();
21+ QMutexLocker lock(&amp;cacheMutex);
22 <xsl:if test="column[@name = 'id']">
23 idCache.insert( entry.id(), entry );
24 </xsl:if>
25 <xsl:if test="column[@name = 'name']">
26 nameCache.insert( entry.name(), entry );
27 </xsl:if>
28- cacheMutex.unlock();
29 }
30
31
32@@ -264,12 +263,10 @@ int <xsl:value-of select="$className"/>::count( const QString &amp;column, const
33 bool <xsl:value-of select="$className"/>::exists( qint64 id )
34 {
35 if ( Private::cacheEnabled ) {
36- Private::cacheMutex.lock();
37+ QMutexLocker lock(&amp;Private::cacheMutex);
38 if ( Private::idCache.contains( id ) ) {
39- Private::cacheMutex.unlock();
40 return true;
41 }
42- Private::cacheMutex.unlock();
43 }
44 return count( idColumn(), id ) > 0;
45 }
46@@ -278,12 +275,10 @@ bool <xsl:value-of select="$className"/>::exists( qint64 id )
47 bool <xsl:value-of select="$className"/>::exists( const <xsl:value-of select="column[@name = 'name']/@type"/> &amp;name )
48 {
49 if ( Private::cacheEnabled ) {
50- Private::cacheMutex.lock();
51+ QMutexLocker lock(&amp;Private::cacheMutex);
52 if ( Private::nameCache.contains( name ) ) {
53- Private::cacheMutex.unlock();
54 return true;
55 }
56- Private::cacheMutex.unlock();
57 }
58 return count( nameColumn(), name ) > 0;
59 }
60@@ -588,28 +583,26 @@ bool <xsl:value-of select="$className"/>::remove( qint64 id )
61 void <xsl:value-of select="$className"/>::invalidateCache() const
62 {
63 if ( Private::cacheEnabled ) {
64- Private::cacheMutex.lock();
65+ QMutexLocker lock(&amp;Private::cacheMutex);
66 <xsl:if test="column[@name = 'id']">
67 Private::idCache.remove( id() );
68 </xsl:if>
69 <xsl:if test="column[@name = 'name']">
70 Private::nameCache.remove( name() );
71 </xsl:if>
72- Private::cacheMutex.unlock();
73 }
74 }
75
76 void <xsl:value-of select="$className"/>::invalidateCompleteCache()
77 {
78 if ( Private::cacheEnabled ) {
79- Private::cacheMutex.lock();
80+ QMutexLocker lock(&amp;Private::cacheMutex);
81 <xsl:if test="column[@name = 'id']">
82 Private::idCache.clear();
83 </xsl:if>
84 <xsl:if test="column[@name = 'name']">
85 Private::nameCache.clear();
86 </xsl:if>
87- Private::cacheMutex.unlock();
88 }
89 }
90
91diff --git a/server/src/storage/entities.xsl b/server/src/storage/entities.xsl
92index 8b0ed03..a397544 100644
93--- a/server/src/storage/entities.xsl
94+++ b/server/src/storage/entities.xsl
95@@ -167,13 +167,11 @@ set<xsl:value-of select="$methodName"/>( <xsl:call-template name="argument"/> )
96 <xsl:variable name="className"><xsl:value-of select="@name"/></xsl:variable>
97 <xsl:if test="$cache != ''">
98 if ( Private::cacheEnabled ) {
99- Private::cacheMutex.lock();
100+ QMutexLocker lock(&amp;Private::cacheMutex);
101 if ( Private::<xsl:value-of select="$cache"/>.contains( <xsl:value-of select="$key"/> ) ) {
102 const <xsl:value-of select="$className"/> tmp = Private::<xsl:value-of select="$cache"/>.value( <xsl:value-of select="$key"/> );
103- Private::cacheMutex.unlock();
104 return tmp;
105 }
106- Private::cacheMutex.unlock();
107 }
108 </xsl:if>
109 QSqlDatabase db = DataStore::self()->database();
110--
1112.1.0
112
This page took 0.049608 seconds and 4 git commands to generate.