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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\include\kernel\msgqueue.h
18 #ifndef __MSGQUEUE_H__
19 #define __MSGQUEUE_H__
20 #include <kernel/kernel.h>
26 class DMsgQueue : public DObject
29 enum TQueueState {EEmpty, EPartial, EFull};
30 enum {KMaxLength = 256};
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;
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);
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