Safir SDK Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AceDispatcher.h
Go to the documentation of this file.
1 /******************************************************************************
2 *
3 * Copyright Saab AB, 2008-2013 (http://safir.sourceforge.net)
4 *
5 * Created by: Erik Adolfsson / sterad
6 *
7 *******************************************************************************
8 *
9 * This file is part of Safir SDK Core.
10 *
11 * Safir SDK Core is free software: you can redistribute it and/or modify
12 * it under the terms of version 3 of the GNU General Public License as
13 * published by the Free Software Foundation.
14 *
15 * Safir SDK Core is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with Safir SDK Core. If not, see <http://www.gnu.org/licenses/>.
22 *
23 ******************************************************************************/
24 #ifndef __DOB_UTILITIES_ACE_DISPATCHER_H__
25 #define __DOB_UTILITIES_ACE_DISPATCHER_H__
26 
27 #include <boost/noncopyable.hpp>
28 #include <Safir/Dob/Connection.h>
29 #include <Safir/Dob/Internal/Atomic.h>
30 
31 #ifdef _MSC_VER
32 #pragma warning (push)
33 #pragma warning (disable: 4127 4244 4251)
34 #endif
35 
36 #include <ace/Reactor.h>
37 
38 #ifdef _MSC_VER
39 #pragma warning (pop)
40 #endif
41 
42 namespace Safir
43 {
44 namespace Utilities
45 {
46 
52  public ACE_Event_Handler,
53  private boost::noncopyable
54  {
55  public:
63  ACE_Event_Handler(ACE_Reactor::instance()),
64  m_connection(connection),
65  m_isNotified(0){}
66 
75  ACE_Reactor * reactor):
76  ACE_Event_Handler(reactor),
77  m_connection(connection),
78  m_isNotified(0){}
79 
80  private:
81 
86  virtual int handle_exception(ACE_HANDLE)
87  {
88  m_isNotified = 0;
89  m_connection.Dispatch();
90  return 0;
91  }
92 
97  virtual void OnDoDispatch()
98  {
99  if (m_isNotified == 0)
100  {
101  m_isNotified = 1;
102  reactor()->notify(this);
103  }
104  }
105 
106 
107  const Safir::Dob::Connection& m_connection;
108  Safir::Dob::Internal::AtomicUint32 m_isNotified;
109 };
110 
111 } // namespace Utilities
112 } // namespace Safir
113 
114 #endif // __DOB_UTILITIES_ACE_DISPATCHER_H__
Interface for reception of a dispatch order.
Definition: Consumer.h:72
The class makes a thread switch and perform a dispatch on Dob connection.
Definition: AceDispatcher.h:50
void Dispatch() const
When the dispatch event or callback is signalled, the application MUST call this method.
AceDispatcher(const Safir::Dob::Connection &connection)
Constructor.
Definition: AceDispatcher.h:62
A connection to the DOB.
Definition: Dob/Connection.h:45
AceDispatcher(const Safir::Dob::Connection &connection, ACE_Reactor *reactor)
Constructor.
Definition: AceDispatcher.h:74