1 karl 1.47 //%2006////////////////////////////////////////////////////////////////////////
|
2 mike 1.2 //
|
3 karl 1.42 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.39 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.42 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.44 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.47 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 mike 1.2 //
|
14 mike 1.5 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
15 chip 1.30 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
18 mike 1.2 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
|
20 karl 1.47 //
|
21 chip 1.30 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
22 mike 1.2 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
24 chip 1.30 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
27 mike 1.2 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 // Author: Mike Day (mdday@us.ibm.com)
33 //
|
34 a.arora 1.40 // Modified By: Amit K Arora, IBM (amita@in.ibm.com) for Bug#1188
|
35 a.arora 1.41 // Alagaraja Ramasubramanian (alags_raj@in.ibm.com) for Bug#1090
|
36 david.dillard 1.45 // David Dillard, VERITAS Software Corp.
37 // (david.dillard@veritas.com)
|
38 kumpf 1.50 // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
|
39 mike 1.2 //
40 //%/////////////////////////////////////////////////////////////////////////////
41
42 #ifndef Pegasus_AsyncOpNode_h
43 #define Pegasus_AsyncOpNode_h
44
45 #include <Pegasus/Common/Config.h>
|
46 kumpf 1.50 #include <Pegasus/Common/Linkage.h>
47 #include <Pegasus/Common/Linkable.h>
48 #include <Pegasus/Common/AutoPtr.h>
|
49 mike 1.2 #include <Pegasus/Common/Message.h>
50 #include <Pegasus/Common/IPC.h>
|
51 kumpf 1.50 #include <Pegasus/Common/Thread.h>
|
52 mike 1.2
53 PEGASUS_NAMESPACE_BEGIN
|
54 mike 1.5
|
55 mike 1.2 #define ASYNC_OPFLAGS_UNKNOWN 0x00000000
56 #define ASYNC_OPFLAGS_NORMAL 0x00000000
57 #define ASYNC_OPFLAGS_SINGLE 0x00000008
|
58 mday 1.13 #define ASYNC_OPFLAGS_META_DISPATCHER 0x00000040
|
59 mday 1.17 #define ASYNC_OPFLAGS_FIRE_AND_FORGET 0x00000080
60 #define ASYNC_OPFLAGS_SIMPLE_STATUS 0x00000100
61 #define ASYNC_OPFLAGS_CALLBACK 0x00000200
|
62 mday 1.20 #define ASYNC_OPFLAGS_FORWARD 0x00000400
|
63 mday 1.24 #define ASYNC_OPFLAGS_PSEUDO_CALLBACK 0x00000800
|
64 mday 1.26 #define ASYNC_OPFLAGS_SAFE_CALLBACK 0x00001000
|
65 mike 1.2
66 #define ASYNC_OPSTATE_UNKNOWN 0x00000000
67 #define ASYNC_OPSTATE_PROCESSING 0x00000008
68 #define ASYNC_OPSTATE_COMPLETE 0x00000040
|
69 mday 1.12 #define ASYNC_OPSTATE_RELEASED 0x00002000
|
70 mike 1.2
|
71 mike 1.48 class PEGASUS_COMMON_LINKAGE AsyncOpNode : public Linkable
|
72 mike 1.2 {
|
73 kumpf 1.50 public:
74
75 AsyncOpNode();
76 ~AsyncOpNode();
|
77 mday 1.26
|
78 kumpf 1.50 void setRequest(Message* request);
79 Message* getRequest();
80 Message* removeRequest();
81
82 void setResponse(Message* response);
83 Message* getResponse();
84 Message* removeResponse();
85
86 Uint32 getState();
87
88 void lock();
89 void unlock();
90
91 void processing();
92 void complete();
93 void release();
94
95 private:
96 AsyncOpNode(const AsyncOpNode&);
97 AsyncOpNode& operator=(const AsyncOpNode&);
98
99 kumpf 1.50 Semaphore _client_sem;
100 Mutex _mut;
101 AutoPtr<Message> _request;
102 AutoPtr<Message> _response;
103
104 Uint32 _state;
105 Uint32 _flags;
106 Uint32 _completion_code;
107 MessageQueue *_op_dest;
108
109 void (*_async_callback)(AsyncOpNode *, MessageQueue *, void *);
110 void (*__async_callback)(Message *, void *, void *);
111
112 // pointers for async callbacks - don't use
113 AsyncOpNode *_callback_node;
114 MessageQueue *_callback_request_q;
115 MessageQueue *_callback_response_q;
116 void *_callback_ptr;
117 void *_callback_parameter;
118 void *_callback_handle;
119
120 kumpf 1.50 // pointers to help static class message handlers - don't use
121 MessageQueue *_service_ptr;
122 Thread *_thread_ptr;
123
124 friend class cimom;
125 friend class MessageQueueService;
126 friend class ProviderManagerService;
127 friend class BinaryMessageHandler;
|
128 mike 1.2 };
129
130
|
131 kumpf 1.50 inline void AsyncOpNode::setRequest(Message* request)
|
132 mike 1.2 {
|
133 kumpf 1.50 AutoMutex autoMut(_mut);
134 PEGASUS_ASSERT(_request.get() == 0);
135 PEGASUS_ASSERT(request != 0);
136 _request.reset(request);
|
137 mike 1.2 }
138
|
139 kumpf 1.50 inline Message* AsyncOpNode::getRequest()
|
140 mike 1.2 {
|
141 kumpf 1.50 AutoMutex autoMut(_mut);
142 PEGASUS_ASSERT(_request.get() != 0);
143 return _request.get();
|
144 mike 1.2 }
145
|
146 kumpf 1.50 inline Message* AsyncOpNode::removeRequest()
|
147 mike 1.2 {
|
148 kumpf 1.50 AutoMutex autoMut(_mut);
149 PEGASUS_ASSERT(_request.get() != 0);
150 Message* request = _request.get();
151 _request.release();
152 return request;
|
153 mike 1.2 }
154
|
155 kumpf 1.50 inline void AsyncOpNode::setResponse(Message* response)
|
156 mike 1.2 {
|
157 kumpf 1.50 AutoMutex autoMut(_mut);
158 PEGASUS_ASSERT(_response.get() == 0);
159 PEGASUS_ASSERT(response != 0);
160 _response.reset(response);
|
161 mike 1.2 }
162
|
163 kumpf 1.50 inline Message* AsyncOpNode::getResponse()
|
164 mike 1.2 {
|
165 kumpf 1.50 AutoMutex autoMut(_mut);
166 PEGASUS_ASSERT(_response.get() != 0);
167 return _response.get();
|
168 mike 1.2 }
169
|
170 kumpf 1.50 inline Message* AsyncOpNode::removeResponse()
|
171 mike 1.2 {
|
172 kumpf 1.50 AutoMutex autoMut(_mut);
173 PEGASUS_ASSERT(_response.get() != 0);
174 Message* response = _response.get();
175 _response.release();
176 return response;
|
177 mike 1.2 }
178
|
179 kumpf 1.50 inline Uint32 AsyncOpNode::getState()
|
180 mike 1.2 {
|
181 kumpf 1.50 AutoMutex autoMut(_mut);
182 return _state;
|
183 mike 1.2 }
184
|
185 kumpf 1.50 inline void AsyncOpNode::lock()
|
186 mike 1.2 {
|
187 kumpf 1.50 _mut.lock(pegasus_thread_self());
|
188 mike 1.2 }
189
|
190 kumpf 1.50 inline void AsyncOpNode::unlock()
|
191 chip 1.30 {
|
192 kumpf 1.50 _mut.unlock();
|
193 mike 1.2 }
194
|
195 kumpf 1.50 inline void AsyncOpNode::processing()
|
196 mike 1.2 {
|
197 kumpf 1.50 AutoMutex autoMut(_mut);
198 _state |= ASYNC_OPSTATE_PROCESSING;
|
199 mike 1.2 }
200
|
201 kumpf 1.50 inline void AsyncOpNode::complete()
|
202 mike 1.2 {
|
203 kumpf 1.50 AutoMutex autoMut(_mut);
204 _state |= ASYNC_OPSTATE_COMPLETE;
|
205 mike 1.2 }
|
206 chip 1.30
|
207 kumpf 1.50 inline void AsyncOpNode::release()
|
208 mike 1.2 {
|
209 kumpf 1.50 AutoMutex autoMut(_mut);
210 _state |= ASYNC_OPSTATE_RELEASED;
|
211 chip 1.30 }
|
212 mike 1.2
213 PEGASUS_NAMESPACE_END
214
215 #endif //Pegasus_AsyncOpNode_h
|