diff -r 000000000000 -r c40eb8fe8501 wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/inc/wllddcircularbuffer.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/inc/wllddcircularbuffer.inl Tue Feb 02 02:03:13 2010 +0200 @@ -0,0 +1,171 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of RWlanCircularBuffer inline methods. +* +*/ + +/* +* %version: 2 % +*/ + +#include // for Kern::SystemTime() + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +template +inline void RWlanCircularBuffer::DoInit() + { + iSize = size; + iPacketAmount = 0; + iGetIndex = 0; + iPutIndex = 0; + iBecameEmptyAt = 0; + } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +template +inline void RWlanCircularBuffer::Release() + { + // Do nothing + } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +template +inline TBool RWlanCircularBuffer::IsEmpty() const + { + return iPacketAmount == 0 ? ETrue : EFalse; + } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +template +inline TBool RWlanCircularBuffer::IsFull() const + { + return iPacketAmount == iSize ? ETrue : EFalse; + } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +template +inline TDataBuffer* RWlanCircularBuffer::GetPacket() + { + TDataBuffer* packet = NULL; + + if ( !IsEmpty() ) + { + packet = iBuffer[iGetIndex]; + + if ( ++iGetIndex == iSize ) + { + iGetIndex = 0; + } + + if ( --iPacketAmount == 0 ) + { + iBecameEmptyAt = Kern::SystemTime(); + } + } + + return packet; + } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +template +inline TBool RWlanCircularBuffer::PutPacket( TDataBuffer* aPacket ) + { + TBool ret( EFalse ); + + if ( !IsFull() ) + { + iBuffer[iPutIndex] = aPacket; + + if ( ++iPutIndex == iSize ) + { + iPutIndex = 0; + } + + ++iPacketAmount; + ret = ETrue; + } + + return ret; + } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +template +inline TDataBuffer* RWlanCircularBuffer::PeekPacket() + { + TDataBuffer* packet = NULL; + + if ( !IsEmpty() ) + { + packet = iBuffer[iGetIndex]; + } + + return packet; + } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +template +inline TUint RWlanCircularBuffer::GetLength() const + { + return iPacketAmount; + } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +template +inline TBool RWlanCircularBuffer::IsActive( TInt64 aTimeNow ) const + { + const TInt64 KActivityThreshold ( 25000 ); // microseconds + + if ( !IsEmpty() ) + { + return ETrue; + } + else + { + if ( aTimeNow - iBecameEmptyAt > KActivityThreshold ) + { + return EFalse; + } + else + { + return ETrue; + } + } + }