os/kernelhwsrv/kernel/eka/include/kernel/msgqueue.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.
     1 // Copyright (c) 2002-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\include\kernel\msgqueue.h
    15 // 
    16 //
    17 
    18 #ifndef __MSGQUEUE_H__
    19 #define __MSGQUEUE_H__
    20 #include <kernel/kernel.h>
    21 #include "nk_priv.h"
    22 
    23 /**
    24 @internalComponent
    25 */
    26 class DMsgQueue : public DObject
    27 	{
    28 public:
    29 	enum TQueueState {EEmpty, EPartial, EFull};
    30 	enum {KMaxLength = 256};
    31 public:
    32 	~DMsgQueue();
    33 	TInt Create(DObject* aOwner, const TDesC* aName, TInt aMsgLength, TInt aSlotCount, TBool aVisible = ETrue);
    34 	TInt Send(const TAny* aPtr, TInt aLength);
    35 	TInt Receive(TAny* aPtr, TInt aLength);
    36 	void NotifySpaceAvailable(TRequestStatus* aStatus);
    37 	void NotifyDataAvailable(TRequestStatus* aStatus);
    38 	void CancelSpaceAvailable();
    39 	void CancelDataAvailable();
    40 	TInt MessageSize() const;
    41 private:
    42 	enum TNotification {ESpaceAvailable, EDataAvailable};
    43 	void CompleteRequestIfPending(DThread*& aThread, TClientRequest* aRequest, TInt aCompletionVal);
    44 	void RequestNotification(TNotification aNotification, TRequestStatus* aStatus, DThread*& aThread, TClientRequest* aRequest);
    45 private:
    46 	TUint8* iMsgPool;			//pointer to the block of memory used for the slots
    47 	TUint8* iFirstFreeSlot;		//first free slot in the msg pool unless iState == EFull
    48 	TUint8* iFirstFullSlot;		//first full slot in the pool unless iState == EEmpty
    49 	TUint8* iEndOfPool;			//address after the allocated pool.  
    50 	DThread* iThreadWaitingOnSpaceAvail;	//thread waiting for space available notification
    51 	DThread* iThreadWaitingOnDataAvail;		//thread waiting for data available notification
    52 	TClientRequest* iDataAvailRequest;
    53 	TClientRequest* iSpaceAvailRequest;
    54 	TUint16 iMaxMsgLength;		//max message length in bytes
    55 	TUint8 iState;				//whether the queue is empty, full or in between
    56 	TUint8 iSpare;
    57 public:
    58 	friend class Monitor;
    59 	};
    60 
    61 #endif
    62