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