Akonadi

cachecleaner.h
1/*
2 SPDX-FileCopyrightText: 2007 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "collectionscheduler.h"
10
11#include <QMutex>
12
13namespace Akonadi
14{
15namespace Server
16{
17class Collection;
18class CacheCleaner;
19class AkonadiServer;
20
21/**
22 * A RAII helper class to temporarily stop the CacheCleaner. This allows long-lasting
23 * operations to safely retrieve all data from resource and perform an operation on them
24 * (like move or copy) without risking that the cache will be cleaned in the meanwhile
25 *
26 * The inhibitor is recursive, so it's possible to create multiple instances of the
27 * CacheCleanerInhibitor and the CacheCleaner will be inhibited until all instances
28 * are destroyed again. However it's not possible to inhibit a single inhibitor
29 * multiple times.
30 */
32{
33public:
34 explicit CacheCleanerInhibitor(AkonadiServer &akonadi, bool inhibit = true);
36
37 void inhibit();
38 void uninhibit();
39
40private:
41 Q_DISABLE_COPY(CacheCleanerInhibitor)
42 static QMutex sLock;
43 static int sInhibitCount;
44
45 CacheCleaner *mCleaner = nullptr;
46 bool mInhibited = false;
47};
48
49/**
50 Cache cleaner.
51 */
52class CacheCleaner : public CollectionScheduler
53{
55
56protected:
57 /**
58 Creates a new cache cleaner thread. Use AkThread::create() to create a new instance of CacheCleaner.
59 @param parent The parent object.
60 */
61 explicit CacheCleaner(QObject *parent = nullptr);
62
63public:
64 ~CacheCleaner() override;
65
66protected:
67 void collectionExpired(const Collection &collection) override;
68 int collectionScheduleInterval(const Collection &collection) override;
69 bool hasChanged(const Collection &collection, const Collection &changed) override;
70 bool shouldScheduleCollection(const Collection &collection) override;
71
72private:
73 friend class CacheCleanerInhibitor;
74};
75
76} // namespace Server
77} // namespace Akonadi
Represents a collection of PIM items.
Definition collection.h:62
A RAII helper class to temporarily stop the CacheCleaner.
CacheCleaner(QObject *parent=nullptr)
Creates a new cache cleaner thread.
Helper integration between Akonadi and Qt.
Q_OBJECTQ_OBJECT
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 21 2024 11:57:49 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.