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 //%/////////////////////////////////////////////////////////////////////////////
33
34 #ifndef Pegasus_AsyncOpNode_h
35 #define Pegasus_AsyncOpNode_h
36
37 #include <Pegasus/Common/Config.h>
|
38 kumpf 1.50 #include <Pegasus/Common/Linkage.h>
39 #include <Pegasus/Common/Linkable.h>
40 #include <Pegasus/Common/AutoPtr.h>
|
41 mike 1.2 #include <Pegasus/Common/Message.h>
|
42 kumpf 1.52 #include <Pegasus/Common/MessageQueue.h>
|
43 kumpf 1.50 #include <Pegasus/Common/Thread.h>
|
44 mike 1.2
45 PEGASUS_NAMESPACE_BEGIN
|
46 mike 1.5
|
47 mike 1.2 #define ASYNC_OPFLAGS_UNKNOWN 0x00000000
48 #define ASYNC_OPFLAGS_NORMAL 0x00000000
49 #define ASYNC_OPFLAGS_SINGLE 0x00000008
|
50 mday 1.13 #define ASYNC_OPFLAGS_META_DISPATCHER 0x00000040
|
51 mday 1.17 #define ASYNC_OPFLAGS_FIRE_AND_FORGET 0x00000080
52 #define ASYNC_OPFLAGS_SIMPLE_STATUS 0x00000100
53 #define ASYNC_OPFLAGS_CALLBACK 0x00000200
|
54 kumpf 1.53 #define ASYNC_OPFLAGS_PSEUDO_CALLBACK 0x00000400
55 #define ASYNC_OPFLAGS_SAFE_CALLBACK 0x00000800
|
56 mike 1.2
57 #define ASYNC_OPSTATE_UNKNOWN 0x00000000
58 #define ASYNC_OPSTATE_PROCESSING 0x00000008
59 #define ASYNC_OPSTATE_COMPLETE 0x00000040
|
60 mday 1.12 #define ASYNC_OPSTATE_RELEASED 0x00002000
|
61 mike 1.2
|
62 mike 1.48 class PEGASUS_COMMON_LINKAGE AsyncOpNode : public Linkable
|
63 mike 1.2 {
|
64 kumpf 1.50 public:
65
66 AsyncOpNode();
67 ~AsyncOpNode();
|
68 mday 1.26
|
69 kumpf 1.50 void setRequest(Message* request);
70 Message* getRequest();
71 Message* removeRequest();
72
73 void setResponse(Message* response);
74 Message* getResponse();
75 Message* removeResponse();
76
77 Uint32 getState();
78
79 void lock();
80 void unlock();
81
82 void processing();
83 void complete();
84 void release();
85
86 private:
87 AsyncOpNode(const AsyncOpNode&);
88 AsyncOpNode& operator=(const AsyncOpNode&);
89
90 kumpf 1.50 Semaphore _client_sem;
91 Mutex _mut;
92 AutoPtr<Message> _request;
93 AutoPtr<Message> _response;
94
95 Uint32 _state;
96 Uint32 _flags;
97 Uint32 _completion_code;
98 MessageQueue *_op_dest;
99
100 void (*_async_callback)(AsyncOpNode *, MessageQueue *, void *);
101 void (*__async_callback)(Message *, void *, void *);
102
103 // pointers for async callbacks - don't use
104 AsyncOpNode *_callback_node;
105 MessageQueue *_callback_request_q;
106 MessageQueue *_callback_response_q;
107 void *_callback_ptr;
108 void *_callback_parameter;
109 void *_callback_handle;
110
111 kumpf 1.50 // pointers to help static class message handlers - don't use
112 MessageQueue *_service_ptr;
113 Thread *_thread_ptr;
114
115 friend class cimom;
116 friend class MessageQueueService;
117 friend class ProviderManagerService;
118 friend class BinaryMessageHandler;
|
119 mike 1.2 };
120
121
|
122 kumpf 1.50 inline void AsyncOpNode::setRequest(Message* request)
|
123 mike 1.2 {
|
124 kumpf 1.50 AutoMutex autoMut(_mut);
125 PEGASUS_ASSERT(_request.get() == 0);
126 PEGASUS_ASSERT(request != 0);
127 _request.reset(request);
|
128 mike 1.2 }
129
|
130 kumpf 1.50 inline Message* AsyncOpNode::getRequest()
|
131 mike 1.2 {
|
132 kumpf 1.50 AutoMutex autoMut(_mut);
133 PEGASUS_ASSERT(_request.get() != 0);
134 return _request.get();
|
135 mike 1.2 }
136
|
137 kumpf 1.50 inline Message* AsyncOpNode::removeRequest()
|
138 mike 1.2 {
|
139 kumpf 1.50 AutoMutex autoMut(_mut);
140 PEGASUS_ASSERT(_request.get() != 0);
141 Message* request = _request.get();
142 _request.release();
143 return request;
|
144 mike 1.2 }
145
|
146 kumpf 1.50 inline void AsyncOpNode::setResponse(Message* response)
|
147 mike 1.2 {
|
148 kumpf 1.50 AutoMutex autoMut(_mut);
149 PEGASUS_ASSERT(_response.get() == 0);
150 PEGASUS_ASSERT(response != 0);
151 _response.reset(response);
|
152 mike 1.2 }
153
|
154 kumpf 1.50 inline Message* AsyncOpNode::getResponse()
|
155 mike 1.2 {
|
156 kumpf 1.50 AutoMutex autoMut(_mut);
157 PEGASUS_ASSERT(_response.get() != 0);
158 return _response.get();
|
159 mike 1.2 }
160
|
161 kumpf 1.50 inline Message* AsyncOpNode::removeResponse()
|
162 mike 1.2 {
|
163 kumpf 1.50 AutoMutex autoMut(_mut);
164 PEGASUS_ASSERT(_response.get() != 0);
165 Message* response = _response.get();
166 _response.release();
167 return response;
|
168 mike 1.2 }
169
|
170 kumpf 1.50 inline Uint32 AsyncOpNode::getState()
|
171 mike 1.2 {
|
172 kumpf 1.50 AutoMutex autoMut(_mut);
173 return _state;
|
174 mike 1.2 }
175
|
176 kumpf 1.50 inline void AsyncOpNode::lock()
|
177 mike 1.2 {
|
178 mike 1.51 _mut.lock();
|
179 mike 1.2 }
180
|
181 kumpf 1.50 inline void AsyncOpNode::unlock()
|
182 chip 1.30 {
|
183 kumpf 1.50 _mut.unlock();
|
184 mike 1.2 }
185
|
186 kumpf 1.50 inline void AsyncOpNode::processing()
|
187 mike 1.2 {
|
188 kumpf 1.50 AutoMutex autoMut(_mut);
189 _state |= ASYNC_OPSTATE_PROCESSING;
|
190 mike 1.2 }
191
|
192 kumpf 1.50 inline void AsyncOpNode::complete()
|
193 mike 1.2 {
|
194 kumpf 1.50 AutoMutex autoMut(_mut);
195 _state |= ASYNC_OPSTATE_COMPLETE;
|
196 mike 1.2 }
|
197 chip 1.30
|
198 kumpf 1.50 inline void AsyncOpNode::release()
|
199 mike 1.2 {
|
200 kumpf 1.50 AutoMutex autoMut(_mut);
201 _state |= ASYNC_OPSTATE_RELEASED;
|
202 chip 1.30 }
|
203 mike 1.2
204 PEGASUS_NAMESPACE_END
205
206 #endif //Pegasus_AsyncOpNode_h
|