|
1 // Copyright (c) 1999-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 #ifndef __VWSQUEUE_H__ |
|
18 #define __VWSQUEUE_H__ |
|
19 |
|
20 #include <e32std.h> |
|
21 #include <e32base.h> |
|
22 |
|
23 #include "VWSDEBUG.H" |
|
24 #include "VWSERVER.H" |
|
25 |
|
26 |
|
27 // |
|
28 // Constants. |
|
29 // |
|
30 |
|
31 const TInt KQueueSize=16; |
|
32 |
|
33 |
|
34 // |
|
35 // Forward declarations. |
|
36 // |
|
37 |
|
38 class CVwsEvent; |
|
39 class CVwsServer; |
|
40 |
|
41 |
|
42 /** |
|
43 * The CVwsEventQueue class implements an event queue for processing server and session events. |
|
44 */ |
|
45 class CVwsEventQueue : public CBase |
|
46 { |
|
47 public: |
|
48 CVwsEventQueue(); |
|
49 |
|
50 #ifdef __DO_LOGGING__ |
|
51 CVwsEventQueue(const TDesC& aName); |
|
52 void SetName(const TDesC& aName); |
|
53 #endif |
|
54 ~CVwsEventQueue(); |
|
55 void ProcessEventL(CVwsEvent* aEvent); |
|
56 void HandleEventProcessed(); |
|
57 CVwsEvent* Head() const; |
|
58 CVwsEvent* Tail() const; |
|
59 TInt Count() const; |
|
60 void HandleSessionRemoval(const TThreadId& aClientThreadId); |
|
61 void KickStart(); |
|
62 private: |
|
63 void DeleteHead(); |
|
64 TInt AddToTail(CVwsEvent*& aEvent); |
|
65 TInt RemoveHead(); |
|
66 TInt DoAddToTail(CVwsEvent* aEvent); |
|
67 TInt AddToTailIfNotPair(CVwsEvent*& aEvent); |
|
68 CVwsEvent* At(TInt aIndex); |
|
69 private: |
|
70 enum TState |
|
71 { |
|
72 EEmpty, |
|
73 EProcessing |
|
74 }; |
|
75 private: |
|
76 CVwsEvent* iQueue[KQueueSize]; |
|
77 TInt iQueueStart; |
|
78 TInt iQueueEnd; |
|
79 TInt iQueueSize; |
|
80 TState iState; |
|
81 #ifdef __DO_LOGGING__ |
|
82 TBuf<64> iQueueName; |
|
83 #endif |
|
84 }; |
|
85 |
|
86 |
|
87 /** |
|
88 * The CVwsEvent class is the base class for events which can be processed by the server and session event queues |
|
89 */ |
|
90 class CVwsEvent : public CBase |
|
91 { |
|
92 public: |
|
93 enum TType |
|
94 { |
|
95 ENormal, |
|
96 ERejectPairs |
|
97 }; |
|
98 public: |
|
99 CVwsEvent(TType aType,CVwsEventQueue& aQueue); |
|
100 ~CVwsEvent(); |
|
101 TType Type(); |
|
102 void ReportEventProcessed(); |
|
103 private: |
|
104 friend class CVwsEventQueue; |
|
105 virtual void ProcessEventL()=0; |
|
106 virtual void HandleAddedToQueue(); |
|
107 virtual void HandleLastOnQueue(); |
|
108 virtual void HandleSessionRemoval(const TThreadId& aClientThreadId); |
|
109 private: |
|
110 TType iType; |
|
111 CVwsEventQueue& iQueue; |
|
112 }; |
|
113 |
|
114 |
|
115 #endif |