1 martin 1.70 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.71 //
|
3 martin 1.70 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
|
9 martin 1.71 //
|
10 martin 1.70 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
|
16 martin 1.71 //
|
17 martin 1.70 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.71 //
|
20 martin 1.70 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.71 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.70 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27 martin 1.71 //
|
28 martin 1.70 //////////////////////////////////////////////////////////////////////////
|
29 mday 1.1 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #ifndef Pegasus_MessageQueue_Service_h
33 #define Pegasus_MessageQueue_Service_h
34
35 #include <Pegasus/Common/Config.h>
36 #include <Pegasus/Common/Message.h>
|
37 kumpf 1.34 #include <Pegasus/Common/InternalException.h>
|
38 mday 1.1 #include <Pegasus/Common/Thread.h>
|
39 mike 1.54 #include <Pegasus/Common/ThreadPool.h>
|
40 mday 1.1 #include <Pegasus/Common/AsyncOpNode.h>
41 #include <Pegasus/Common/Cimom.h>
|
42 mike 1.51 #include <Pegasus/Common/Mutex.h>
|
43 mday 1.1 #include <Pegasus/Common/CimomMessage.h>
|
44 kumpf 1.33 #include <Pegasus/Common/Linkage.h>
|
45 mike 1.54 #include <Pegasus/Common/Mutex.h>
|
46 mday 1.1
47 PEGASUS_NAMESPACE_BEGIN
48
|
49 mday 1.10 extern const Uint32 CIMOM_Q_ID;
|
50 mday 1.9
|
51 mday 1.3 class message_module;
|
52 marek 1.56 class cimom;
|
53 mday 1.3
|
54 mike 1.51
|
55 kumpf 1.59 class PEGASUS_COMMON_LINKAGE MessageQueueService :
|
56 venkat.puvvada 1.75 public Linkable, public MessageQueue
|
57 mday 1.1 {
|
58 david.dillard 1.45 public:
59
60 typedef MessageQueue Base;
|
61 mday 1.1
|
62 kumpf 1.55 MessageQueueService(
|
63 kumpf 1.59 const char* name,
|
64 venkat.puvvada 1.66 Uint32 queueID = MessageQueue::getNextQueueId());
|
65 david.dillard 1.45
66 virtual ~MessageQueueService();
67
68 virtual Boolean isAsync() const { return true; }
69
70 virtual void enqueue(Message *);
71
|
72 kumpf 1.59 AsyncReply* SendWait(AsyncRequest* request);
73 Boolean SendAsync(AsyncOpNode* op,
74 Uint32 destination,
75 void (*callback)(AsyncOpNode*, MessageQueue*, void*),
76 MessageQueue* callback_q,
77 void* callback_ptr);
|
78 david.dillard 1.45
|
79 kumpf 1.59 Boolean SendForget(Message* msg);
|
80 david.dillard 1.45
81 Boolean update_service(Uint32 capabilities, Uint32 mask);
82 Boolean deregister_service();
83
|
84 kumpf 1.76 Uint32 find_service_qid(const char* name);
|
85 kumpf 1.59 static AsyncOpNode* get_op();
86 void return_op(AsyncOpNode* op);
|
87 david.dillard 1.45
|
88 kumpf 1.59 static ThreadPool* get_thread_pool();
|
89 david.dillard 1.45
|
90 venkat.puvvada 1.75 AtomicInt _die;
|
91 kumpf 1.59 AtomicInt _threads;
92 Uint32 getIncomingCount() {return _incoming.count(); }
|
93 david.dillard 1.45
94 protected:
|
95 kumpf 1.59 virtual Boolean accept_async(AsyncOpNode* op);
|
96 david.dillard 1.45 virtual void handleEnqueue() = 0;
97 virtual void handleEnqueue(Message *) = 0;
98 Boolean _enqueueResponse(Message *, Message *);
99 virtual void _handle_incoming_operation(AsyncOpNode *);
100
|
101 kumpf 1.59 virtual void _handle_async_request(AsyncRequest* req);
102 virtual void _handle_async_callback(AsyncOpNode* operation);
103 virtual void _make_response(Message* req, Uint32 code);
104
|
105 venkat.puvvada 1.69 virtual void handle_AsyncIoClose(AsyncIoClose* req);
|
106 kumpf 1.59 virtual void handle_CimServiceStart(CimServiceStart* req);
107 virtual void handle_CimServiceStop(CimServiceStop* req);
108
109 void _completeAsyncResponse(
110 AsyncRequest* request,
|
111 venkat.puvvada 1.67 AsyncReply* reply);
112 void _complete_op_node(AsyncOpNode *);
|
113 david.dillard 1.45
|
114 kumpf 1.59 static cimom* _meta_dispatcher;
|
115 venkat.puvvada 1.75 static AtomicInt _service_count;
|
116 venkat.puvvada 1.73 static Mutex _meta_dispatcher_mutex;
|
117 kumpf 1.59 static ThreadPool* _thread_pool;
|
118 venkat.puvvada 1.66 Boolean _isRunning;
|
119 david.dillard 1.45 private:
|
120 venkat.puvvada 1.65 Boolean _sendAsync(AsyncOpNode* op,
121 Uint32 destination,
122 void (*callback)(AsyncOpNode*, MessageQueue*, void*),
123 MessageQueue* callback_q,
124 void* callback_ptr,
125 Uint32 flags);
126
|
127 venkat.puvvada 1.75 void _removeFromPollingList(MessageQueueService *service);
128
|
129 kumpf 1.57 static ThreadReturnType PEGASUS_THREAD_CDECL polling_routine(void *);
130
|
131 mike 1.51 AsyncQueue<AsyncOpNode> _incoming;
|
132 david.dillard 1.45 static Thread* _polling_thread;
133 static Semaphore _polling_sem;
134 static AtomicInt _stop_polling;
135
|
136 venkat.puvvada 1.75 typedef List<MessageQueueService, NullLock> PollingList;
|
137 mike 1.51 static PollingList* _polling_list;
|
138 venkat.puvvada 1.75 static Mutex _polling_list_mutex;
|
139 david.dillard 1.45
|
140 mike 1.54 static ThreadReturnType PEGASUS_THREAD_CDECL _req_proc(void *);
|
141 david.dillard 1.45
142 AtomicInt _incoming_queue_shutdown;
143
144 friend class cimom;
|
145 mday 1.1 };
146
147 PEGASUS_NAMESPACE_END
148
149 #endif /* Pegasus_MessageQueue_Service_h */
|