sl@0: // Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef SQLCOMPACTTIMER_H sl@0: #define SQLCOMPACTTIMER_H sl@0: sl@0: #include sl@0: sl@0: //Forward declarations sl@0: class CSqlCompactTestActive; sl@0: class CSqlCompactEntry; sl@0: sl@0: #ifdef _DEBUG sl@0: #define SQLCOMPACTTIMER_INVARIANT() Invariant() sl@0: #else sl@0: #define SQLCOMPACTTIMER_INVARIANT() void(0) sl@0: #endif sl@0: sl@0: /** sl@0: A CTimer derived class that performs the background compaction. sl@0: The CSqlCompactTimer class maintains a queue of CSqlCompactEntry objects waiting to be compacted sl@0: (the databases). sl@0: The class offers methods for adding/removing CSqlCompactEntry objects to/from the queue and a Restart() sl@0: method that can be used to delay the next compaction step, improving this way the SQL server responsiveness to sl@0: client requests. sl@0: sl@0: The CSqlCompactEntry objects needing compaction will be added at the front of the queue. sl@0: Every time when timer's RunL() method gets executed, the last element from the queue will be picked-up and one sl@0: compaction step will be performed. When the CSqlCompactEntry object completes the compaction, it will remove sl@0: itself from the queue. sl@0: sl@0: @see CSqlCompactEntry sl@0: sl@0: @internalComponent sl@0: */ sl@0: NONSHARABLE_CLASS(CSqlCompactTimer) : protected CTimer sl@0: { sl@0: friend class CSqlCompactTestActive; sl@0: sl@0: public: sl@0: static CSqlCompactTimer* NewL(TInt aIntervalMs); sl@0: virtual ~CSqlCompactTimer(); sl@0: void Restart(); sl@0: void Queue(CSqlCompactEntry& aEntry); sl@0: void DeQueue(CSqlCompactEntry& aEntry); sl@0: void Invariant() const; sl@0: sl@0: private: sl@0: CSqlCompactTimer(TInt aIntervalMs); sl@0: void ConstructL(); sl@0: virtual void RunL(); sl@0: sl@0: private: sl@0: TInt iIntervalMicroSec; sl@0: TSglQue iQueue; sl@0: sl@0: }; sl@0: sl@0: #endif//SQLCOMPACTTIMER_H