Chris@16
|
1 #ifndef BOOST_STATECHART_PROCESSOR_CONTAINER_HPP_INCLUDED
|
Chris@16
|
2 #define BOOST_STATECHART_PROCESSOR_CONTAINER_HPP_INCLUDED
|
Chris@16
|
3 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
4 // Copyright 2002-2008 Andreas Huber Doenni
|
Chris@16
|
5 // Distributed under the Boost Software License, Version 1.0. (See accompany-
|
Chris@16
|
6 // ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
8
|
Chris@16
|
9
|
Chris@16
|
10
|
Chris@16
|
11 #include <boost/statechart/event_base.hpp>
|
Chris@16
|
12 #include <boost/statechart/event_processor.hpp>
|
Chris@16
|
13
|
Chris@16
|
14 #include <boost/assert.hpp>
|
Chris@16
|
15 #include <boost/ref.hpp>
|
Chris@16
|
16 #include <boost/noncopyable.hpp>
|
Chris@16
|
17 #include <boost/intrusive_ptr.hpp>
|
Chris@16
|
18 #include <boost/shared_ptr.hpp>
|
Chris@16
|
19 #include <boost/weak_ptr.hpp>
|
Chris@16
|
20 #include <boost/bind.hpp>
|
Chris@16
|
21 #include <boost/config.hpp> // BOOST_INTEL
|
Chris@16
|
22
|
Chris@16
|
23 #include <boost/detail/workaround.hpp>
|
Chris@16
|
24 #include <boost/detail/allocator_utilities.hpp>
|
Chris@16
|
25
|
Chris@16
|
26 #include <set>
|
Chris@16
|
27 #include <memory> // std::allocator, std::auto_ptr
|
Chris@16
|
28
|
Chris@16
|
29
|
Chris@16
|
30
|
Chris@16
|
31 namespace boost
|
Chris@16
|
32 {
|
Chris@16
|
33 namespace statechart
|
Chris@16
|
34 {
|
Chris@16
|
35 namespace detail
|
Chris@16
|
36 {
|
Chris@16
|
37 template<bool IsReferenceWrapper>
|
Chris@16
|
38 struct unwrap_impl
|
Chris@16
|
39 {
|
Chris@16
|
40 template< typename T >
|
Chris@16
|
41 struct apply { typedef T type; };
|
Chris@16
|
42 };
|
Chris@16
|
43
|
Chris@16
|
44 template<>
|
Chris@16
|
45 struct unwrap_impl<true>
|
Chris@16
|
46 {
|
Chris@16
|
47 template< typename T >
|
Chris@16
|
48 struct apply { typedef typename T::type & type; };
|
Chris@16
|
49 };
|
Chris@16
|
50
|
Chris@16
|
51 template<typename T>
|
Chris@16
|
52 struct unwrap
|
Chris@16
|
53 {
|
Chris@16
|
54 typedef typename unwrap_impl<
|
Chris@16
|
55 is_reference_wrapper< T >::value >::template apply< T >::type type;
|
Chris@16
|
56 };
|
Chris@16
|
57 }
|
Chris@16
|
58
|
Chris@16
|
59
|
Chris@16
|
60 template<
|
Chris@16
|
61 class Scheduler,
|
Chris@16
|
62 class WorkItem,
|
Chris@16
|
63 class Allocator = std::allocator< void > >
|
Chris@16
|
64 class processor_container : noncopyable
|
Chris@16
|
65 {
|
Chris@16
|
66 typedef event_processor< Scheduler > processor_base_type;
|
Chris@16
|
67 typedef std::auto_ptr< processor_base_type > processor_holder_type;
|
Chris@16
|
68 typedef shared_ptr< processor_holder_type > processor_holder_ptr_type;
|
Chris@16
|
69
|
Chris@16
|
70 public:
|
Chris@16
|
71 //////////////////////////////////////////////////////////////////////////
|
Chris@16
|
72 typedef weak_ptr< processor_holder_type > processor_handle;
|
Chris@16
|
73
|
Chris@16
|
74 class processor_context
|
Chris@16
|
75 {
|
Chris@16
|
76 processor_context(
|
Chris@16
|
77 Scheduler & scheduler, const processor_handle & handle
|
Chris@16
|
78 ) :
|
Chris@16
|
79 scheduler_( scheduler ),
|
Chris@16
|
80 handle_( handle )
|
Chris@16
|
81 {
|
Chris@16
|
82 }
|
Chris@16
|
83
|
Chris@16
|
84 #if BOOST_WORKAROUND( BOOST_INTEL, BOOST_TESTED_AT( 800 ) )
|
Chris@16
|
85 public:
|
Chris@16
|
86 // for some reason Intel 8.0 seems to think that the following functions
|
Chris@16
|
87 // are inaccessible from event_processor<>::event_processor
|
Chris@16
|
88 #endif
|
Chris@16
|
89
|
Chris@16
|
90 Scheduler & my_scheduler() const { return scheduler_; }
|
Chris@16
|
91 const processor_handle & my_handle() const { return handle_; }
|
Chris@16
|
92
|
Chris@16
|
93 #if BOOST_WORKAROUND( BOOST_INTEL, BOOST_TESTED_AT( 800 ) )
|
Chris@16
|
94 private:
|
Chris@16
|
95 #endif
|
Chris@16
|
96
|
Chris@16
|
97 // avoids C4512 (assignment operator could not be generated)
|
Chris@16
|
98 processor_context & operator=( const processor_context & );
|
Chris@16
|
99
|
Chris@16
|
100 Scheduler & scheduler_;
|
Chris@16
|
101 const processor_handle handle_;
|
Chris@16
|
102
|
Chris@16
|
103 friend class processor_container;
|
Chris@16
|
104 friend class event_processor< Scheduler >;
|
Chris@16
|
105 };
|
Chris@16
|
106
|
Chris@16
|
107 template< class Processor >
|
Chris@16
|
108 WorkItem create_processor( processor_handle & handle, Scheduler & scheduler )
|
Chris@16
|
109 {
|
Chris@16
|
110 processor_holder_ptr_type pProcessor = make_processor_holder();
|
Chris@16
|
111 handle = pProcessor;
|
Chris@16
|
112 typedef void ( processor_container::*impl_fun_ptr )(
|
Chris@16
|
113 const processor_holder_ptr_type &, const processor_context & );
|
Chris@16
|
114 impl_fun_ptr pImpl =
|
Chris@16
|
115 &processor_container::template create_processor_impl0< Processor >;
|
Chris@16
|
116 return WorkItem(
|
Chris@16
|
117 boost::bind( pImpl, this, pProcessor,
|
Chris@16
|
118 processor_context( scheduler, handle ) ),
|
Chris@16
|
119 Allocator() );
|
Chris@16
|
120 }
|
Chris@16
|
121
|
Chris@16
|
122 template< class Processor, typename Arg1 >
|
Chris@16
|
123 WorkItem create_processor(
|
Chris@16
|
124 processor_handle & handle, Scheduler & scheduler, Arg1 arg1 )
|
Chris@16
|
125 {
|
Chris@16
|
126 processor_holder_ptr_type pProcessor = make_processor_holder();
|
Chris@16
|
127 handle = pProcessor;
|
Chris@16
|
128 typedef typename detail::unwrap< Arg1 >::type arg1_type;
|
Chris@16
|
129 typedef void ( processor_container::*impl_fun_ptr )(
|
Chris@16
|
130 const processor_holder_ptr_type &, const processor_context &,
|
Chris@16
|
131 arg1_type );
|
Chris@16
|
132 impl_fun_ptr pImpl =
|
Chris@16
|
133 &processor_container::template create_processor_impl1<
|
Chris@16
|
134 Processor, arg1_type >;
|
Chris@16
|
135 return WorkItem(
|
Chris@16
|
136 boost::bind( pImpl, this, pProcessor, processor_context( scheduler, handle ),
|
Chris@16
|
137 arg1 ),
|
Chris@16
|
138 Allocator() );
|
Chris@16
|
139 }
|
Chris@16
|
140
|
Chris@16
|
141 template< class Processor, typename Arg1, typename Arg2 >
|
Chris@16
|
142 WorkItem create_processor(
|
Chris@16
|
143 processor_handle & handle, Scheduler & scheduler, Arg1 arg1, Arg2 arg2 )
|
Chris@16
|
144 {
|
Chris@16
|
145 processor_holder_ptr_type pProcessor = make_processor_holder();
|
Chris@16
|
146 handle = pProcessor;
|
Chris@16
|
147 typedef typename detail::unwrap< Arg1 >::type arg1_type;
|
Chris@16
|
148 typedef typename detail::unwrap< Arg2 >::type arg2_type;
|
Chris@16
|
149 typedef void ( processor_container::*impl_fun_ptr )(
|
Chris@16
|
150 const processor_holder_ptr_type &, const processor_context &,
|
Chris@16
|
151 arg1_type, arg2_type );
|
Chris@16
|
152 impl_fun_ptr pImpl =
|
Chris@16
|
153 &processor_container::template create_processor_impl2<
|
Chris@16
|
154 Processor, arg1_type, arg2_type >;
|
Chris@16
|
155 return WorkItem(
|
Chris@16
|
156 boost::bind( pImpl, this, pProcessor, processor_context( scheduler, handle ),
|
Chris@16
|
157 arg1, arg2 ),
|
Chris@16
|
158 Allocator() );
|
Chris@16
|
159 }
|
Chris@16
|
160
|
Chris@16
|
161 template< class Processor, typename Arg1, typename Arg2, typename Arg3 >
|
Chris@16
|
162 WorkItem create_processor(
|
Chris@16
|
163 processor_handle & handle, Scheduler & scheduler,
|
Chris@16
|
164 Arg1 arg1, Arg2 arg2, Arg3 arg3 )
|
Chris@16
|
165 {
|
Chris@16
|
166 processor_holder_ptr_type pProcessor = make_processor_holder();
|
Chris@16
|
167 handle = pProcessor;
|
Chris@16
|
168 typedef typename detail::unwrap< Arg1 >::type arg1_type;
|
Chris@16
|
169 typedef typename detail::unwrap< Arg2 >::type arg2_type;
|
Chris@16
|
170 typedef typename detail::unwrap< Arg3 >::type arg3_type;
|
Chris@16
|
171 typedef void ( processor_container::*impl_fun_ptr )(
|
Chris@16
|
172 const processor_holder_ptr_type &, const processor_context &,
|
Chris@16
|
173 arg1_type, arg2_type, arg3_type );
|
Chris@16
|
174 impl_fun_ptr pImpl =
|
Chris@16
|
175 &processor_container::template create_processor_impl3<
|
Chris@16
|
176 Processor, arg1_type, arg2_type, arg3_type >;
|
Chris@16
|
177 return WorkItem(
|
Chris@16
|
178 boost::bind( pImpl, this, pProcessor, processor_context( scheduler, handle ),
|
Chris@16
|
179 arg1, arg2, arg3 ),
|
Chris@16
|
180 Allocator() );
|
Chris@16
|
181 }
|
Chris@16
|
182
|
Chris@16
|
183 template<
|
Chris@16
|
184 class Processor, typename Arg1, typename Arg2,
|
Chris@16
|
185 typename Arg3, typename Arg4 >
|
Chris@16
|
186 WorkItem create_processor(
|
Chris@16
|
187 processor_handle & handle, Scheduler & scheduler,
|
Chris@16
|
188 Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4 )
|
Chris@16
|
189 {
|
Chris@16
|
190 processor_holder_ptr_type pProcessor = make_processor_holder();
|
Chris@16
|
191 handle = pProcessor;
|
Chris@16
|
192 typedef typename detail::unwrap< Arg1 >::type arg1_type;
|
Chris@16
|
193 typedef typename detail::unwrap< Arg2 >::type arg2_type;
|
Chris@16
|
194 typedef typename detail::unwrap< Arg3 >::type arg3_type;
|
Chris@16
|
195 typedef typename detail::unwrap< Arg4 >::type arg4_type;
|
Chris@16
|
196 typedef void ( processor_container::*impl_fun_ptr )(
|
Chris@16
|
197 const processor_holder_ptr_type &, const processor_context &,
|
Chris@16
|
198 arg1_type, arg2_type, arg3_type, arg4_type );
|
Chris@16
|
199 impl_fun_ptr pImpl =
|
Chris@16
|
200 &processor_container::template create_processor_impl4<
|
Chris@16
|
201 Processor, arg1_type, arg2_type, arg3_type, arg4_type >;
|
Chris@16
|
202 return WorkItem(
|
Chris@16
|
203 boost::bind( pImpl, this, pProcessor, processor_context( scheduler, handle ),
|
Chris@16
|
204 arg1, arg2, arg3, arg4 ),
|
Chris@16
|
205 Allocator() );
|
Chris@16
|
206 }
|
Chris@16
|
207
|
Chris@16
|
208 template<
|
Chris@16
|
209 class Processor, typename Arg1, typename Arg2,
|
Chris@16
|
210 typename Arg3, typename Arg4, typename Arg5 >
|
Chris@16
|
211 WorkItem create_processor(
|
Chris@16
|
212 processor_handle & handle, Scheduler & scheduler,
|
Chris@16
|
213 Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5 )
|
Chris@16
|
214 {
|
Chris@16
|
215 processor_holder_ptr_type pProcessor = make_processor_holder();
|
Chris@16
|
216 handle = pProcessor;
|
Chris@16
|
217 typedef typename detail::unwrap< Arg1 >::type arg1_type;
|
Chris@16
|
218 typedef typename detail::unwrap< Arg2 >::type arg2_type;
|
Chris@16
|
219 typedef typename detail::unwrap< Arg3 >::type arg3_type;
|
Chris@16
|
220 typedef typename detail::unwrap< Arg4 >::type arg4_type;
|
Chris@16
|
221 typedef typename detail::unwrap< Arg5 >::type arg5_type;
|
Chris@16
|
222 typedef void ( processor_container::*impl_fun_ptr )(
|
Chris@16
|
223 const processor_holder_ptr_type &, const processor_context &,
|
Chris@16
|
224 arg1_type, arg2_type, arg3_type, arg4_type, arg5_type );
|
Chris@16
|
225 impl_fun_ptr pImpl =
|
Chris@16
|
226 &processor_container::template create_processor_impl5<
|
Chris@16
|
227 Processor, arg1_type, arg2_type, arg3_type, arg4_type, arg5_type >;
|
Chris@16
|
228 return WorkItem(
|
Chris@16
|
229 boost::bind( pImpl, this, pProcessor, processor_context( scheduler, handle ),
|
Chris@16
|
230 arg1, arg2, arg3, arg4, arg5 ),
|
Chris@16
|
231 Allocator() );
|
Chris@16
|
232 }
|
Chris@16
|
233
|
Chris@16
|
234 template<
|
Chris@16
|
235 class Processor, typename Arg1, typename Arg2,
|
Chris@16
|
236 typename Arg3, typename Arg4, typename Arg5, typename Arg6 >
|
Chris@16
|
237 WorkItem create_processor(
|
Chris@16
|
238 processor_handle & handle, Scheduler & scheduler,
|
Chris@16
|
239 Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6 )
|
Chris@16
|
240 {
|
Chris@16
|
241 processor_holder_ptr_type pProcessor = make_processor_holder();
|
Chris@16
|
242 handle = pProcessor;
|
Chris@16
|
243 typedef typename detail::unwrap< Arg1 >::type arg1_type;
|
Chris@16
|
244 typedef typename detail::unwrap< Arg2 >::type arg2_type;
|
Chris@16
|
245 typedef typename detail::unwrap< Arg3 >::type arg3_type;
|
Chris@16
|
246 typedef typename detail::unwrap< Arg4 >::type arg4_type;
|
Chris@16
|
247 typedef typename detail::unwrap< Arg5 >::type arg5_type;
|
Chris@16
|
248 typedef typename detail::unwrap< Arg6 >::type arg6_type;
|
Chris@16
|
249 typedef void ( processor_container::*impl_fun_ptr )(
|
Chris@16
|
250 const processor_holder_ptr_type &, const processor_context &,
|
Chris@16
|
251 arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type );
|
Chris@16
|
252 impl_fun_ptr pImpl =
|
Chris@16
|
253 &processor_container::template create_processor_impl6<
|
Chris@16
|
254 Processor,
|
Chris@16
|
255 arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type >;
|
Chris@16
|
256 return WorkItem(
|
Chris@16
|
257 boost::bind( pImpl, this, pProcessor, processor_context( scheduler, handle ),
|
Chris@16
|
258 arg1, arg2, arg3, arg4, arg5, arg6 ),
|
Chris@16
|
259 Allocator() );
|
Chris@16
|
260 }
|
Chris@16
|
261
|
Chris@16
|
262 WorkItem destroy_processor( const processor_handle & processor )
|
Chris@16
|
263 {
|
Chris@16
|
264 return WorkItem(
|
Chris@16
|
265 boost::bind( &processor_container::destroy_processor_impl, this, processor ),
|
Chris@16
|
266 Allocator() );
|
Chris@16
|
267 }
|
Chris@16
|
268
|
Chris@16
|
269 WorkItem initiate_processor( const processor_handle & processor )
|
Chris@16
|
270 {
|
Chris@16
|
271 return WorkItem(
|
Chris@16
|
272 boost::bind( &processor_container::initiate_processor_impl, this,
|
Chris@16
|
273 processor ),
|
Chris@16
|
274 Allocator() );
|
Chris@16
|
275 }
|
Chris@16
|
276
|
Chris@16
|
277 WorkItem terminate_processor( const processor_handle & processor )
|
Chris@16
|
278 {
|
Chris@16
|
279 return WorkItem(
|
Chris@16
|
280 boost::bind( &processor_container::terminate_processor_impl, this,
|
Chris@16
|
281 processor ),
|
Chris@16
|
282 Allocator() );
|
Chris@16
|
283 }
|
Chris@16
|
284
|
Chris@16
|
285 typedef intrusive_ptr< const event_base > event_ptr_type;
|
Chris@16
|
286
|
Chris@16
|
287 WorkItem queue_event(
|
Chris@16
|
288 const processor_handle & processor, const event_ptr_type & pEvent )
|
Chris@16
|
289 {
|
Chris@16
|
290 BOOST_ASSERT( pEvent.get() != 0 );
|
Chris@16
|
291
|
Chris@16
|
292 return WorkItem(
|
Chris@16
|
293 boost::bind( &processor_container::queue_event_impl, this, processor,
|
Chris@16
|
294 pEvent ),
|
Chris@16
|
295 Allocator() );
|
Chris@16
|
296 }
|
Chris@16
|
297
|
Chris@16
|
298 private:
|
Chris@16
|
299 //////////////////////////////////////////////////////////////////////////
|
Chris@16
|
300 processor_holder_ptr_type make_processor_holder()
|
Chris@16
|
301 {
|
Chris@16
|
302 return processor_holder_ptr_type( new processor_holder_type() );
|
Chris@16
|
303 }
|
Chris@16
|
304
|
Chris@16
|
305 template< class Processor >
|
Chris@16
|
306 void create_processor_impl0(
|
Chris@16
|
307 const processor_holder_ptr_type & pProcessor,
|
Chris@16
|
308 const processor_context & context )
|
Chris@16
|
309 {
|
Chris@16
|
310 processorSet_.insert( pProcessor );
|
Chris@16
|
311 processor_holder_type holder( new Processor( context ) );
|
Chris@16
|
312 *pProcessor = holder;
|
Chris@16
|
313 }
|
Chris@16
|
314
|
Chris@16
|
315 template< class Processor, typename Arg1 >
|
Chris@16
|
316 void create_processor_impl1(
|
Chris@16
|
317 const processor_holder_ptr_type & pProcessor,
|
Chris@16
|
318 const processor_context & context, Arg1 arg1 )
|
Chris@16
|
319 {
|
Chris@16
|
320 processorSet_.insert( pProcessor );
|
Chris@16
|
321 processor_holder_type holder( new Processor( context, arg1 ) );
|
Chris@16
|
322 *pProcessor = holder;
|
Chris@16
|
323 }
|
Chris@16
|
324
|
Chris@16
|
325 template< class Processor, typename Arg1, typename Arg2 >
|
Chris@16
|
326 void create_processor_impl2(
|
Chris@16
|
327 const processor_holder_ptr_type & pProcessor,
|
Chris@16
|
328 const processor_context & context, Arg1 arg1, Arg2 arg2 )
|
Chris@16
|
329 {
|
Chris@16
|
330 processorSet_.insert( pProcessor );
|
Chris@16
|
331 processor_holder_type holder( new Processor( context, arg1, arg2 ) );
|
Chris@16
|
332 *pProcessor = holder;
|
Chris@16
|
333 }
|
Chris@16
|
334
|
Chris@16
|
335 template< class Processor, typename Arg1, typename Arg2, typename Arg3 >
|
Chris@16
|
336 void create_processor_impl3(
|
Chris@16
|
337 const processor_holder_ptr_type & pProcessor,
|
Chris@16
|
338 const processor_context & context, Arg1 arg1, Arg2 arg2, Arg3 arg3 )
|
Chris@16
|
339 {
|
Chris@16
|
340 processorSet_.insert( pProcessor );
|
Chris@16
|
341 processor_holder_type holder(
|
Chris@16
|
342 new Processor( context, arg1, arg2, arg3 ) );
|
Chris@16
|
343 *pProcessor = holder;
|
Chris@16
|
344 }
|
Chris@16
|
345
|
Chris@16
|
346 template<
|
Chris@16
|
347 class Processor, typename Arg1, typename Arg2,
|
Chris@16
|
348 typename Arg3, typename Arg4 >
|
Chris@16
|
349 void create_processor_impl4(
|
Chris@16
|
350 const processor_holder_ptr_type & pProcessor,
|
Chris@16
|
351 const processor_context & context,
|
Chris@16
|
352 Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4 )
|
Chris@16
|
353 {
|
Chris@16
|
354 processorSet_.insert( pProcessor );
|
Chris@16
|
355 processor_holder_type holder(
|
Chris@16
|
356 new Processor( context, arg1, arg2, arg3, arg4 ) );
|
Chris@16
|
357 *pProcessor = holder;
|
Chris@16
|
358 }
|
Chris@16
|
359
|
Chris@16
|
360 template<
|
Chris@16
|
361 class Processor, typename Arg1, typename Arg2,
|
Chris@16
|
362 typename Arg3, typename Arg4, typename Arg5 >
|
Chris@16
|
363 void create_processor_impl5(
|
Chris@16
|
364 const processor_holder_ptr_type & pProcessor,
|
Chris@16
|
365 const processor_context & context,
|
Chris@16
|
366 Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5 )
|
Chris@16
|
367 {
|
Chris@16
|
368 processorSet_.insert( pProcessor );
|
Chris@16
|
369 processor_holder_type holder(
|
Chris@16
|
370 new Processor( context, arg1, arg2, arg3, arg4, arg5 ) );
|
Chris@16
|
371 *pProcessor = holder;
|
Chris@16
|
372 }
|
Chris@16
|
373
|
Chris@16
|
374 template<
|
Chris@16
|
375 class Processor, typename Arg1, typename Arg2,
|
Chris@16
|
376 typename Arg3, typename Arg4, typename Arg5, typename Arg6 >
|
Chris@16
|
377 void create_processor_impl6(
|
Chris@16
|
378 const processor_holder_ptr_type & pProcessor,
|
Chris@16
|
379 const processor_context & context,
|
Chris@16
|
380 Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6 )
|
Chris@16
|
381 {
|
Chris@16
|
382 processorSet_.insert( pProcessor );
|
Chris@16
|
383 processor_holder_type holder(
|
Chris@16
|
384 new Processor( context, arg1, arg2, arg3, arg4, arg5, arg6 ) );
|
Chris@16
|
385 *pProcessor = holder;
|
Chris@16
|
386 }
|
Chris@16
|
387
|
Chris@16
|
388 void destroy_processor_impl( const processor_handle & processor )
|
Chris@16
|
389 {
|
Chris@16
|
390 const processor_holder_ptr_type pProcessor = processor.lock();
|
Chris@16
|
391
|
Chris@16
|
392 if ( pProcessor != 0 )
|
Chris@16
|
393 {
|
Chris@16
|
394 processorSet_.erase( pProcessor );
|
Chris@16
|
395 }
|
Chris@16
|
396 }
|
Chris@16
|
397
|
Chris@16
|
398 void initiate_processor_impl( const processor_handle & processor )
|
Chris@16
|
399 {
|
Chris@16
|
400 const processor_holder_ptr_type pProcessor = processor.lock();
|
Chris@16
|
401
|
Chris@16
|
402 if ( pProcessor != 0 )
|
Chris@16
|
403 {
|
Chris@16
|
404 ( *pProcessor )->initiate();
|
Chris@16
|
405 }
|
Chris@16
|
406 }
|
Chris@16
|
407
|
Chris@16
|
408 void terminate_processor_impl( const processor_handle & processor )
|
Chris@16
|
409 {
|
Chris@16
|
410 const processor_holder_ptr_type pProcessor = processor.lock();
|
Chris@16
|
411
|
Chris@16
|
412 if ( pProcessor != 0 )
|
Chris@16
|
413 {
|
Chris@16
|
414 ( *pProcessor )->terminate();
|
Chris@16
|
415 }
|
Chris@16
|
416 }
|
Chris@16
|
417
|
Chris@16
|
418 void queue_event_impl(
|
Chris@16
|
419 const processor_handle & processor, const event_ptr_type & pEvent )
|
Chris@16
|
420 {
|
Chris@16
|
421 const processor_holder_ptr_type pProcessor = processor.lock();
|
Chris@16
|
422
|
Chris@16
|
423 if ( pProcessor != 0 )
|
Chris@16
|
424 {
|
Chris@16
|
425 ( *pProcessor )->process_event( *pEvent );
|
Chris@16
|
426 }
|
Chris@16
|
427 }
|
Chris@16
|
428
|
Chris@16
|
429 typedef std::set<
|
Chris@16
|
430 processor_holder_ptr_type,
|
Chris@16
|
431 std::less< processor_holder_ptr_type >,
|
Chris@16
|
432 typename boost::detail::allocator::rebind_to<
|
Chris@16
|
433 Allocator, processor_holder_ptr_type >::type
|
Chris@16
|
434 > event_processor_set_type;
|
Chris@16
|
435
|
Chris@16
|
436 event_processor_set_type processorSet_;
|
Chris@16
|
437 };
|
Chris@16
|
438
|
Chris@16
|
439
|
Chris@16
|
440 } // namespace statechart
|
Chris@16
|
441 } // namespace boost
|
Chris@16
|
442
|
Chris@16
|
443
|
Chris@16
|
444
|
Chris@16
|
445 #endif
|