diff -r c1e808730d6c -r eedf2dcd43c6 omxil/omxilcomponentcommon/src/common/primsgqueue.inl --- a/omxil/omxilcomponentcommon/src/common/primsgqueue.inl Mon May 03 13:56:28 2010 +0300 +++ b/omxil/omxilcomponentcommon/src/common/primsgqueue.inl Fri May 07 16:25:23 2010 +0100 @@ -1,156 +1,156 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "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: -// - - -/** - @file - @internalComponent -*/ - - -template -inline RPriMsgQueue::TFrontQueueElement::TFrontQueueElement( - const TAny* apInfo) - : - ipInfo(apInfo) - { - iLink.iPriority = 0; - } - -template -inline RPriMsgQueue::TFrontQueueElement::TFrontQueueElement( - const TAny* apInfo, TInt aPriority) - : - ipInfo(apInfo) - { - iLink.iPriority = aPriority; - } - -template -inline TInt RPriMsgQueue::CreateLocal(TInt aSize, TOwnerType aOwner) - { - iFrontQueue.SetOffset(_FOFF(TFrontQueueElement, iLink)); - return iBackQueue.CreateLocal(aSize, sizeof(T), aOwner); - } - -template -inline TInt RPriMsgQueue::Handle() const - { - return iBackQueue.Handle(); - } - -template -inline TInt RPriMsgQueue::Send(const T& aMsg) - { - ASSERT(aMsg); - return iBackQueue.Send(&aMsg, sizeof(T)); - } - -template -inline TInt RPriMsgQueue::Receive(T& aMsg) - { - TInt err = DrainBackQueue(); - if (KErrNone == err) - { - if (iFrontQueue.IsEmpty()) - { - return KErrUnderflow; - } - - TFrontQueueElement* pElement = iFrontQueue.First(); - __ASSERT_DEBUG(pElement != 0, - User::Panic(RPriMsgQueuePanicCategory, 1)); - pElement->iLink.Deque(); - aMsg = reinterpret_cast(const_cast(pElement->ipInfo)); - delete pElement; - } - - return err; - - } - -template -inline void RPriMsgQueue::Close() - { - - // Back queue should be empty by now, but just in case... - - // Here we expect a pointer type!... - T pElement; - while (iBackQueue.Receive(&pElement, sizeof(T)) == KErrNone) - { - delete pElement; - pElement = 0; - } - iBackQueue.Close(); - - // Front queue should be empty by now, but just in case... - TFrontQueueElement* pFQElement = 0; - while (!iFrontQueue.IsEmpty()) - { - pFQElement = iFrontQueue.First(); - __ASSERT_DEBUG(pFQElement != 0, - User::Panic(RPriMsgQueuePanicCategory, 1)); - pFQElement->iLink.Deque(); - pElement = reinterpret_cast(const_cast(pFQElement->ipInfo)); - delete pElement; - delete pFQElement; - } - - } - -template -inline void RPriMsgQueue::NotifyDataAvailable(TRequestStatus& aStatus) - { - iBackQueue.NotifyDataAvailable(aStatus); - } - -template -inline void RPriMsgQueue::CancelDataAvailable() - { - iBackQueue.CancelDataAvailable(); - } - -template -TInt RPriMsgQueue::DrainBackQueue() - { - - // Here we expect a pointer type!... - T pElement; - while (iBackQueue.Receive(&pElement, sizeof(T)) == KErrNone) - { - TFrontQueueElement* pElem = - new TFrontQueueElement(pElement, pElement->Priority()); - - // This double attempt at allocation is done in order to allow OOM - // tests to pass, as there is no way to report an error to the client - // if we lose a RegisterCallbacks message in an OOM situation - if (!pElem) - { - pElem = new TFrontQueueElement(pElement, pElement->Priority()); - } - - if (!pElem) - { - // This command will get lost, but at least it won't be leaked - delete pElement; - return KErrNoMemory; - } - iFrontQueue.Add(*pElem); - } - - return KErrNone; - - } +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "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: +// + + +/** + @file + @internalComponent +*/ + + +template +inline RPriMsgQueue::TFrontQueueElement::TFrontQueueElement( + const TAny* apInfo) + : + ipInfo(apInfo) + { + iLink.iPriority = 0; + } + +template +inline RPriMsgQueue::TFrontQueueElement::TFrontQueueElement( + const TAny* apInfo, TInt aPriority) + : + ipInfo(apInfo) + { + iLink.iPriority = aPriority; + } + +template +inline TInt RPriMsgQueue::CreateLocal(TInt aSize, TOwnerType aOwner) + { + iFrontQueue.SetOffset(_FOFF(TFrontQueueElement, iLink)); + return iBackQueue.CreateLocal(aSize, sizeof(T), aOwner); + } + +template +inline TInt RPriMsgQueue::Handle() const + { + return iBackQueue.Handle(); + } + +template +inline TInt RPriMsgQueue::Send(const T& aMsg) + { + ASSERT(aMsg); + return iBackQueue.Send(&aMsg, sizeof(T)); + } + +template +inline TInt RPriMsgQueue::Receive(T& aMsg) + { + TInt err = DrainBackQueue(); + if (KErrNone == err) + { + if (iFrontQueue.IsEmpty()) + { + return KErrUnderflow; + } + + TFrontQueueElement* pElement = iFrontQueue.First(); + __ASSERT_DEBUG(pElement != 0, + User::Panic(RPriMsgQueuePanicCategory, 1)); + pElement->iLink.Deque(); + aMsg = reinterpret_cast(const_cast(pElement->ipInfo)); + delete pElement; + } + + return err; + + } + +template +inline void RPriMsgQueue::Close() + { + + // Back queue should be empty by now, but just in case... + + // Here we expect a pointer type!... + T pElement; + while (iBackQueue.Receive(&pElement, sizeof(T)) == KErrNone) + { + delete pElement; + pElement = 0; + } + iBackQueue.Close(); + + // Front queue should be empty by now, but just in case... + TFrontQueueElement* pFQElement = 0; + while (!iFrontQueue.IsEmpty()) + { + pFQElement = iFrontQueue.First(); + __ASSERT_DEBUG(pFQElement != 0, + User::Panic(RPriMsgQueuePanicCategory, 1)); + pFQElement->iLink.Deque(); + pElement = reinterpret_cast(const_cast(pFQElement->ipInfo)); + delete pElement; + delete pFQElement; + } + + } + +template +inline void RPriMsgQueue::NotifyDataAvailable(TRequestStatus& aStatus) + { + iBackQueue.NotifyDataAvailable(aStatus); + } + +template +inline void RPriMsgQueue::CancelDataAvailable() + { + iBackQueue.CancelDataAvailable(); + } + +template +TInt RPriMsgQueue::DrainBackQueue() + { + + // Here we expect a pointer type!... + T pElement; + while (iBackQueue.Receive(&pElement, sizeof(T)) == KErrNone) + { + TFrontQueueElement* pElem = + new TFrontQueueElement(pElement, pElement->Priority()); + + // This double attempt at allocation is done in order to allow OOM + // tests to pass, as there is no way to report an error to the client + // if we lose a RegisterCallbacks message in an OOM situation + if (!pElem) + { + pElem = new TFrontQueueElement(pElement, pElement->Priority()); + } + + if (!pElem) + { + // This command will get lost, but at least it won't be leaked + delete pElement; + return KErrNoMemory; + } + iFrontQueue.Add(*pElem); + } + + return KErrNone; + + }