0
|
1 |
// Copyright (c) 2004-2009 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 the License "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 |
// e32\euser\cbase\ub_tque.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include <e32std.h>
|
|
19 |
#include <e32std_private.h>
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
// Class TTickCountQue
|
|
25 |
/**
|
|
26 |
@internalComponent
|
|
27 |
@released
|
|
28 |
|
|
29 |
Constructs an empty list header
|
|
30 |
*/
|
|
31 |
TTickCountQue::TTickCountQue()
|
|
32 |
{}
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
/**
|
|
38 |
@internalComponent
|
|
39 |
@released
|
|
40 |
|
|
41 |
Adds the specified list element.
|
|
42 |
|
|
43 |
The element is added into the list in order of its tick count.
|
|
44 |
|
|
45 |
@param aRef The list element to be inserted.
|
|
46 |
*/
|
|
47 |
void TTickCountQue::Add(TTickCountQueLink& aRef)
|
|
48 |
{
|
|
49 |
TTickCountQueLink* currentLink = (TTickCountQueLink*)(iHead.iNext);
|
|
50 |
TTickCountQueLink* addLink = &aRef;
|
|
51 |
|
|
52 |
while ( (currentLink != (TTickCountQueLink*)&iHead) &&
|
|
53 |
(((TInt)(addLink->iTickCount - currentLink->iTickCount)) >= 0)
|
|
54 |
)
|
|
55 |
{
|
|
56 |
currentLink = (TTickCountQueLink*)currentLink->iNext;
|
|
57 |
}
|
|
58 |
|
|
59 |
addLink->Enque(currentLink->iPrev);
|
|
60 |
}
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
/**
|
|
66 |
@internalComponent
|
|
67 |
@released
|
|
68 |
|
|
69 |
Removes the first list element from the linked list if its tick count
|
|
70 |
is prior to the current tick count.
|
|
71 |
|
|
72 |
@param aTickCount The current tick count.
|
|
73 |
|
|
74 |
@return A pointer to the element removed from the linked list. This is NULL
|
|
75 |
if the first element has yet to expire or the queue is empty.
|
|
76 |
*/
|
|
77 |
TTickCountQueLink* TTickCountQue::RemoveFirst(TUint aTickCount)
|
|
78 |
{
|
|
79 |
TTickCountQueLink* firstLink = (TTickCountQueLink*)iHead.iNext;
|
|
80 |
|
|
81 |
if (((TInt)(firstLink->iTickCount - aTickCount)) <= 0)
|
|
82 |
{
|
|
83 |
return RemoveFirst();
|
|
84 |
}
|
|
85 |
else
|
|
86 |
{
|
|
87 |
return NULL;
|
|
88 |
}
|
|
89 |
}
|
|
90 |
|
|
91 |
|
|
92 |
/**
|
|
93 |
@internalComponent
|
|
94 |
@released
|
|
95 |
|
|
96 |
Removes the first list element from the linked list, if any.
|
|
97 |
|
|
98 |
@return A pointer to the element removed from the linked list. This is NULL,
|
|
99 |
if the queue is empty.
|
|
100 |
*/
|
|
101 |
TTickCountQueLink* TTickCountQue::RemoveFirst()
|
|
102 |
{
|
|
103 |
TTickCountQueLink* firstLink = (TTickCountQueLink*)iHead.iNext;
|
|
104 |
|
|
105 |
if (firstLink != (TTickCountQueLink*)&iHead)
|
|
106 |
{
|
|
107 |
firstLink->Deque();
|
|
108 |
return firstLink;
|
|
109 |
}
|
|
110 |
|
|
111 |
return NULL;
|
|
112 |
}
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
|
117 |
/**
|
|
118 |
@internalComponent
|
|
119 |
@released
|
|
120 |
|
|
121 |
Gets a pointer to the first list element in the doubly linked list.
|
|
122 |
|
|
123 |
@return A pointer to the first list element in the doubly linked list. If
|
|
124 |
the list is empty, this pointer is not necessarily NULL and must not
|
|
125 |
be assumed to point to a valid object.
|
|
126 |
*/
|
|
127 |
TTickCountQueLink* TTickCountQue::First() const
|
|
128 |
{
|
|
129 |
#if defined (_DEBUG)
|
|
130 |
__DbgTestEmpty();
|
|
131 |
#endif
|
|
132 |
return((TTickCountQueLink*)iHead.iNext);
|
|
133 |
}
|