|
1 /* |
|
2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Custom plug-in implementations offer their own API documentation |
|
15 * where detailed characteristics about how methods declared in this |
|
16 * class are implemented. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 #ifndef SEN_SERVICE_DISPATCHER_H |
|
28 #define SEN_SERVICE_DISPATCHER_H |
|
29 |
|
30 #include <flogger.h> |
|
31 #include <e32property.h> |
|
32 #include <e32std.h> |
|
33 #include "senlogger.h" |
|
34 #include "sendebug.h" |
|
35 |
|
36 typedef RSenPointerMap<TInt, TInt> RTransactionsMap; |
|
37 |
|
38 // FORWARD DECLARATIONS |
|
39 class CSenConnectionChunk; |
|
40 class CSenAsyncOperation; |
|
41 class CSenServiceConnectionImpl; |
|
42 |
|
43 struct TMessage |
|
44 { |
|
45 CSenConnectionChunk* iSenConnectionChunk; // Not Owned |
|
46 CSenAsyncOperation* iSenAsyncOperation; // Not Owned |
|
47 }; |
|
48 |
|
49 struct TThreadMessage |
|
50 { |
|
51 TMessage iMessage; |
|
52 TInt iVrtalTrnsnID; |
|
53 }; |
|
54 |
|
55 #ifdef EKA2 |
|
56 NONSHARABLE_CLASS(CSenServiceDispatcher) : public CBase |
|
57 #else |
|
58 class CSenServiceDispatcher : public CBase |
|
59 #endif |
|
60 { |
|
61 private: |
|
62 protected: |
|
63 public: |
|
64 |
|
65 // Constructors and destructor: |
|
66 static CSenServiceDispatcher* NewL( RSenServiceConnection& aConnection, |
|
67 TInt aConnectionID); |
|
68 |
|
69 static CSenServiceDispatcher* NewLC( RSenServiceConnection& aConnection, |
|
70 TInt aConnectionID); |
|
71 |
|
72 |
|
73 static TInt DispatcherThreadL(CSenServiceDispatcher* aThis); |
|
74 |
|
75 static TInt ExecuteL(CSenServiceDispatcher* aThis); |
|
76 |
|
77 TInt GetDispactherThreadId(); |
|
78 |
|
79 TInt AddToTheQueue(TThreadMessage aThreadMessage); |
|
80 |
|
81 TBool RemoveFromQueue(TInt aTransactionID); |
|
82 |
|
83 TInt AddToTheTransMap(TInt* pVrtlaTxnId,TInt* pActlTxnId); |
|
84 |
|
85 TInt RemoveFromTransMap(TInt* pVrtlaTxnId); |
|
86 |
|
87 TInt UpdateTransMap(TInt* pVrtlaTxnId,TInt* pActlTxnId); |
|
88 |
|
89 TInt GetActualTransactionID(TInt* pVrtlaTxnId); |
|
90 |
|
91 TInt GetVirtualTransactionID(TInt* pActlTxnId); |
|
92 |
|
93 void SetOwnerThreadId(TInt aOwnerThreadID); |
|
94 |
|
95 void ResetQueue(); |
|
96 |
|
97 TMessage GetMessageFromQueue(TInt aTransactionID); |
|
98 |
|
99 virtual ~CSenServiceDispatcher(); |
|
100 |
|
101 private: |
|
102 |
|
103 /** |
|
104 * C++ default constructor. |
|
105 */ |
|
106 CSenServiceDispatcher(RSenServiceConnection& aConnection); |
|
107 |
|
108 /** |
|
109 * By default Symbian 2nd phase constructor is private. |
|
110 */ |
|
111 void ConstructL(TInt aConnectionID); |
|
112 |
|
113 RTransactionsMap& TransactionMap(); |
|
114 |
|
115 void OpenDispatcherLogL(); |
|
116 |
|
117 void CloseDispatcherLogL(); |
|
118 |
|
119 private: |
|
120 |
|
121 RThread iDispatcherThread; |
|
122 |
|
123 //Message queue to dispacth messages in FIFO order. |
|
124 RArray<TThreadMessage> iMessageQueue; |
|
125 TInt iMessagesQueueCounter; |
|
126 |
|
127 //Map of virtual and actual transaction ID's. |
|
128 RTransactionsMap* ipTransactionsMap; |
|
129 |
|
130 //Flag for dispatching messages. Stops dispatching messages |
|
131 //when set to FALSE. |
|
132 TBool iDispatchMessages; |
|
133 |
|
134 //Synchronizer critical section. Used to lock while dispatching |
|
135 //messages. |
|
136 RCriticalSection iCsSynchronizer; |
|
137 |
|
138 //Crtitical senction for message queue. |
|
139 RCriticalSection iCsMessageQueue; |
|
140 |
|
141 //Crtitical senction for transaction map. |
|
142 RCriticalSection iCsTransctnsMap; |
|
143 |
|
144 TThreadId iOwnerThreadId; |
|
145 RSenServiceConnection& iConnection; // not owned |
|
146 TInt iConnectionID; |
|
147 |
|
148 }; |
|
149 |
|
150 #ifdef EKA2 |
|
151 NONSHARABLE_CLASS(CSenUnderTakerWaiter) : public CActive |
|
152 #else |
|
153 class CSenUnderTakerWaiter : public CActive |
|
154 #endif |
|
155 { |
|
156 public: |
|
157 // Constructors and destructor |
|
158 static CSenUnderTakerWaiter* NewL(CSenServiceConnectionImpl* aSenServiceConnectionImpl, |
|
159 TInt aDispatcherThreadID ); |
|
160 static CSenUnderTakerWaiter* NewLC(CSenServiceConnectionImpl* aSenServiceConnectionImpl, |
|
161 TInt aDispatcherThreadID); |
|
162 |
|
163 void StartWaiter(); |
|
164 void StopWaiter(); |
|
165 |
|
166 ~CSenUnderTakerWaiter(); |
|
167 |
|
168 private: |
|
169 CSenUnderTakerWaiter(); |
|
170 void ConstructL(CSenServiceConnectionImpl* aSenServiceConnectionImpl, |
|
171 TInt iDispatcherThreadID ); |
|
172 void RunL(); |
|
173 void DoCancel(); |
|
174 private: // Data |
|
175 CSenServiceConnectionImpl* iSenServiceConnectionImpl; // not owned |
|
176 RUndertaker iUnderTaker; |
|
177 TInt iDyingThreadNumber ; |
|
178 TInt iDispatcherThreadID ; |
|
179 }; |
|
180 |
|
181 #endif //SEN_SERVICE_DISPATCHER_H |
|
182 |
|
183 // End of File |