• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ------------------------------------------------------------------
2  * Copyright (C) 1998-2009 PacketVideo
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13  * express or implied.
14  * See the License for the specific language governing permissions
15  * and limitations under the License.
16  * -------------------------------------------------------------------
17  */
18 
19 #ifndef OSCL_SOCKET_SERV_IMP_REQLIST_H_INCLUDED
20 #define OSCL_SOCKET_SERV_IMP_REQLIST_H_INCLUDED
21 
22 #include "oscl_socket_tuneables.h"
23 #include "oscl_defalloc.h"
24 #include "oscl_vector.h"
25 #include "oscl_mem.h"
26 
27 #if PV_SOCKET_SERVER_IS_THREAD
28 #include "oscl_semaphore.h"
29 #include "oscl_mutex.h"
30 #endif
31 
32 class OsclSocketServI;
33 template<class T>class OsclSocketQueue;
34 class OsclSocketI;
35 class OsclSocketRequest;
36 
37 class OsclSocketServRequestQElem
38 {
39     public:
OsclSocketServRequestQElem(OsclSocketRequest * r)40         OsclSocketServRequestQElem(OsclSocketRequest* r)
41                 : iSocketRequest(r)
42                 , iSelect(0)
43                 , iCancel(false)
44         {}
45 
46         OsclSocketRequest* iSocketRequest;
47         uint8 iSelect;
48         bool iCancel;
49 };
50 
51 /** PV socket server request queue
52 */
53 class OsclSocketServRequestList
54 {
55     public:
56         OsclSocketServRequestList();
57         void Add(OsclSocketRequest *);
58         void StartCancel(OsclSocketRequest *);
59         void Open(OsclSocketServI*s);
60         void Close();
61         void Wakeup();
62         void WaitOnRequests();
Remove(OsclSocketServRequestQElem * aElem)63         void Remove(OsclSocketServRequestQElem* aElem)
64         {
65             aElem->iSocketRequest = NULL;
66         }
67 
68     private:
69         //a queue of the active sockets.
70         Oscl_Vector<OsclSocketServRequestQElem, OsclMemAllocator> iActiveRequests;
71 
72 #if PV_SOCKET_SERVER_IS_THREAD
73         //thread protection
74         OsclMutex iCrit;
75         OsclSemaphore iSem;
76 #endif
77 
78         OsclSocketServI *iContainer;
79 
80         //input queues for requests from the app side.  requests
81         //are picked up by server thread, so these queues need
82         //to be used with thread locks.
83         Oscl_Vector<OsclSocketRequest*, OsclMemAllocator> iAddRequests;
84         Oscl_Vector<OsclSocketRequest*, OsclMemAllocator> iCancelRequests;
85         void GetNewRequests();
86         void Lock();
87         void Unlock();
88 
89         friend class OsclSocketServI;
90 };
91 
92 
93 #endif
94 
95 
96 
97