|
1 // Copyright (c) 2008-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 "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 // |
|
15 |
|
16 |
|
17 /** |
|
18 @file |
|
19 @internalComponent |
|
20 */ |
|
21 |
|
22 #ifndef PRIMSGQUEUE_H |
|
23 #define PRIMSGQUEUE_H |
|
24 |
|
25 #include <e32std.h> |
|
26 #include <e32msgqueue.h> |
|
27 |
|
28 /** |
|
29 RPriMsgQueue panic category |
|
30 */ |
|
31 _LIT(RPriMsgQueuePanicCategory, "RPriMsgQueue"); |
|
32 |
|
33 /** |
|
34 A priority-based message queue similar to RMsQueue . |
|
35 |
|
36 This templated class provides the behaviour for managing an asynchronous |
|
37 queue of messages, ordered by descending priority order, where the template |
|
38 parameter defines the message type. Note that this message queue is intended |
|
39 to be used with pointer types only. Also, message types are assumed to have |
|
40 a member with the following signature : TInt Priority() |
|
41 |
|
42 */ |
|
43 template <typename T> |
|
44 class RPriMsgQueue |
|
45 { |
|
46 |
|
47 public: |
|
48 |
|
49 inline TInt CreateLocal(TInt aSize, TOwnerType aType=EOwnerProcess); |
|
50 inline TInt Handle() const; |
|
51 inline TInt Send(const T& aMsg); |
|
52 inline TInt Receive(T& aMsg); |
|
53 inline void Close(); |
|
54 inline void NotifyDataAvailable(TRequestStatus& aStatus); |
|
55 inline void CancelDataAvailable(); |
|
56 |
|
57 protected: |
|
58 |
|
59 class TFrontQueueElement |
|
60 { |
|
61 |
|
62 public: |
|
63 |
|
64 inline explicit TFrontQueueElement(const TAny* apInfo); |
|
65 inline TFrontQueueElement(const TAny* apInfo, TInt aPriority); |
|
66 |
|
67 public: |
|
68 |
|
69 const TAny* ipInfo; |
|
70 TPriQueLink iLink; |
|
71 |
|
72 }; |
|
73 |
|
74 protected: |
|
75 |
|
76 inline TInt DrainBackQueue(); |
|
77 |
|
78 protected: |
|
79 |
|
80 RMsgQueueBase iBackQueue; |
|
81 TPriQue<TFrontQueueElement> iFrontQueue; |
|
82 |
|
83 }; |
|
84 |
|
85 #include "primsgqueue.inl" |
|
86 |
|
87 #endif // PRIMSGQUEUE_H |