1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sql/SRC/Server/Compact/SqlCompactTimer.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,71 @@
1.4 +// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef SQLCOMPACTTIMER_H
1.20 +#define SQLCOMPACTTIMER_H
1.21 +
1.22 +#include <e32base.h>
1.23 +
1.24 +//Forward declarations
1.25 +class CSqlCompactTestActive;
1.26 +class CSqlCompactEntry;
1.27 +
1.28 +#ifdef _DEBUG
1.29 +#define SQLCOMPACTTIMER_INVARIANT() Invariant()
1.30 +#else
1.31 +#define SQLCOMPACTTIMER_INVARIANT() void(0)
1.32 +#endif
1.33 +
1.34 +/**
1.35 +A CTimer derived class that performs the background compaction.
1.36 +The CSqlCompactTimer class maintains a queue of CSqlCompactEntry objects waiting to be compacted
1.37 +(the databases).
1.38 +The class offers methods for adding/removing CSqlCompactEntry objects to/from the queue and a Restart()
1.39 +method that can be used to delay the next compaction step, improving this way the SQL server responsiveness to
1.40 +client requests.
1.41 +
1.42 +The CSqlCompactEntry objects needing compaction will be added at the front of the queue.
1.43 +Every time when timer's RunL() method gets executed, the last element from the queue will be picked-up and one
1.44 +compaction step will be performed. When the CSqlCompactEntry object completes the compaction, it will remove
1.45 +itself from the queue.
1.46 +
1.47 +@see CSqlCompactEntry
1.48 +
1.49 +@internalComponent
1.50 +*/
1.51 +NONSHARABLE_CLASS(CSqlCompactTimer) : protected CTimer
1.52 + {
1.53 + friend class CSqlCompactTestActive;
1.54 +
1.55 +public:
1.56 + static CSqlCompactTimer* NewL(TInt aIntervalMs);
1.57 + virtual ~CSqlCompactTimer();
1.58 + void Restart();
1.59 + void Queue(CSqlCompactEntry& aEntry);
1.60 + void DeQueue(CSqlCompactEntry& aEntry);
1.61 + void Invariant() const;
1.62 +
1.63 +private:
1.64 + CSqlCompactTimer(TInt aIntervalMs);
1.65 + void ConstructL();
1.66 + virtual void RunL();
1.67 +
1.68 +private:
1.69 + TInt iIntervalMicroSec;
1.70 + TSglQue<CSqlCompactEntry> iQueue;
1.71 +
1.72 + };
1.73 +
1.74 +#endif//SQLCOMPACTTIMER_H