os/kernelhwsrv/kernel/eka/euser/cbase/ub_tque.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/euser/cbase/ub_tque.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,133 @@
     1.4 +// Copyright (c) 2004-2009 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 the License "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 +// e32\euser\cbase\ub_tque.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include <e32std.h>
    1.22 +#include <e32std_private.h>
    1.23 +
    1.24 +
    1.25 +
    1.26 +
    1.27 +// Class TTickCountQue
    1.28 +/**
    1.29 +@internalComponent
    1.30 +@released
    1.31 +
    1.32 +Constructs an empty list header
    1.33 +*/
    1.34 +TTickCountQue::TTickCountQue()
    1.35 +	{}
    1.36 +
    1.37 +
    1.38 +
    1.39 +
    1.40 +/**
    1.41 +@internalComponent
    1.42 +@released
    1.43 +
    1.44 +Adds the specified list element.
    1.45 +
    1.46 +The element is added into the list in order of its tick count.
    1.47 +
    1.48 +@param aRef The list element to be inserted.
    1.49 +*/
    1.50 +void TTickCountQue::Add(TTickCountQueLink& aRef)
    1.51 +	{
    1.52 +	TTickCountQueLink* currentLink = (TTickCountQueLink*)(iHead.iNext);
    1.53 +	TTickCountQueLink* addLink = &aRef;
    1.54 +
    1.55 +	while (	(currentLink != (TTickCountQueLink*)&iHead) &&
    1.56 +			(((TInt)(addLink->iTickCount - currentLink->iTickCount)) >= 0)
    1.57 +		)
    1.58 +		{
    1.59 +		currentLink = (TTickCountQueLink*)currentLink->iNext;
    1.60 +		}
    1.61 +
    1.62 +	addLink->Enque(currentLink->iPrev);
    1.63 +	}
    1.64 +
    1.65 +
    1.66 +
    1.67 +
    1.68 +/**
    1.69 +@internalComponent
    1.70 +@released
    1.71 +
    1.72 +Removes the first list element from the linked list if its tick count
    1.73 +is prior to the current tick count.
    1.74 +
    1.75 +@param aTickCount The current tick count.
    1.76 +
    1.77 +@return A pointer to the element removed from the linked list. This is NULL 
    1.78 +        if the first element has yet to expire or the queue is empty.
    1.79 +*/
    1.80 +TTickCountQueLink* TTickCountQue::RemoveFirst(TUint aTickCount)
    1.81 +	{
    1.82 +	TTickCountQueLink* firstLink = (TTickCountQueLink*)iHead.iNext;
    1.83 +
    1.84 +	if (((TInt)(firstLink->iTickCount - aTickCount)) <= 0)
    1.85 +		{
    1.86 +		return RemoveFirst();
    1.87 +		}
    1.88 +	else
    1.89 +		{
    1.90 +		return NULL;
    1.91 +		}
    1.92 +	}
    1.93 +
    1.94 +
    1.95 +/**
    1.96 +@internalComponent
    1.97 +@released
    1.98 +
    1.99 +Removes the first list element from the linked list, if any.
   1.100 +
   1.101 +@return A pointer to the element removed from the linked list. This is NULL, 
   1.102 +        if the queue is empty.
   1.103 +*/
   1.104 +TTickCountQueLink* TTickCountQue::RemoveFirst()
   1.105 +	{
   1.106 +	TTickCountQueLink* firstLink = (TTickCountQueLink*)iHead.iNext;
   1.107 +
   1.108 +	if (firstLink != (TTickCountQueLink*)&iHead)
   1.109 +		{
   1.110 +		firstLink->Deque();
   1.111 +		return firstLink;
   1.112 +		}
   1.113 +
   1.114 +	return NULL;
   1.115 +	}
   1.116 +
   1.117 +
   1.118 +
   1.119 +
   1.120 +/**
   1.121 +@internalComponent
   1.122 +@released
   1.123 +
   1.124 +Gets a pointer to the first list element in the doubly linked list.
   1.125 +
   1.126 +@return A pointer to the first list element in the doubly linked list. If 
   1.127 +        the list is empty, this pointer is not necessarily NULL and must not
   1.128 +		be assumed to point to a valid object.
   1.129 +*/
   1.130 +TTickCountQueLink* TTickCountQue::First() const
   1.131 +	{
   1.132 +#if defined (_DEBUG)
   1.133 +	__DbgTestEmpty();
   1.134 +#endif
   1.135 +    return((TTickCountQueLink*)iHead.iNext);
   1.136 +    }