os/persistentdata/persistentstorage/sql/SRC/Server/Compact/SqlCompactTimer.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef SQLCOMPACTTIMER_H
    17 #define SQLCOMPACTTIMER_H
    18 
    19 #include <e32base.h>
    20 
    21 //Forward declarations
    22 class CSqlCompactTestActive;
    23 class CSqlCompactEntry;
    24 
    25 #ifdef _DEBUG
    26 #define SQLCOMPACTTIMER_INVARIANT() Invariant()
    27 #else
    28 #define SQLCOMPACTTIMER_INVARIANT() void(0)
    29 #endif
    30 
    31 /**
    32 A CTimer derived class that performs the background compaction.
    33 The CSqlCompactTimer class maintains a queue of CSqlCompactEntry objects waiting to be compacted
    34 (the databases).
    35 The class offers methods for adding/removing CSqlCompactEntry objects to/from the queue and a Restart()
    36 method that can be used to delay the next compaction step, improving this way the SQL server responsiveness to 
    37 client requests.
    38 
    39 The CSqlCompactEntry objects needing compaction will be added at the front of the queue.
    40 Every time when timer's RunL() method gets executed, the last element from the queue will be picked-up and one
    41 compaction step will be performed. When the CSqlCompactEntry object completes the compaction, it will remove
    42 itself from the queue.
    43 
    44 @see CSqlCompactEntry
    45 
    46 @internalComponent
    47 */
    48 NONSHARABLE_CLASS(CSqlCompactTimer) : protected CTimer
    49 	{
    50 	friend class CSqlCompactTestActive;
    51 	
    52 public:
    53 	static CSqlCompactTimer* NewL(TInt aIntervalMs);
    54 	virtual ~CSqlCompactTimer();
    55 	void Restart();
    56 	void Queue(CSqlCompactEntry& aEntry);
    57 	void DeQueue(CSqlCompactEntry& aEntry);
    58 	void Invariant() const;
    59 	
    60 private:
    61 	CSqlCompactTimer(TInt aIntervalMs);
    62 	void ConstructL();
    63 	virtual void RunL();
    64 
    65 private:
    66 	TInt						iIntervalMicroSec;
    67 	TSglQue<CSqlCompactEntry>	iQueue;
    68 	
    69 	};
    70 
    71 #endif//SQLCOMPACTTIMER_H