Safir SDK Core
Loading...
Searching...
No Matches
AceDispatcher.h
Go to the documentation of this file.
1/******************************************************************************
2*
3* Copyright Saab AB, 2008-2013 (http://safirsdkcore.com)
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#ifndef SAFIR_NO_DEPRECATED
28
29#include <boost/noncopyable.hpp>
31#include <atomic>
32
33#ifdef _MSC_VER
34#pragma warning (push)
35#pragma warning (disable: 4127 4244 4251)
36#endif
37
38#include <ace/Reactor.h>
39
40#ifdef _MSC_VER
41#pragma warning (pop)
42#endif
43
44namespace Safir
45{
46namespace Utilities
47{
48
57 public ACE_Event_Handler,
58 private boost::noncopyable
59 {
60 public:
68 ACE_Event_Handler(ACE_Reactor::instance()),
69 m_connection(connection),
70 m_isNotified(){}
71
80 ACE_Reactor * reactor):
81 ACE_Event_Handler(reactor),
82 m_connection(connection),
83 m_isNotified(){}
84
85 private:
86
91 int handle_exception(ACE_HANDLE) override
92 {
93 m_isNotified.clear();
94 m_connection.Dispatch();
95 return 0;
96 }
97
102 void OnDoDispatch() override
103 {
104 if (!m_isNotified.test_and_set())
105 {
106 reactor()->notify(this);
107 }
108 }
109
110
111 const Safir::Dob::Connection& m_connection;
112 std::atomic_flag m_isNotified;
113};
114
115} // namespace Utilities
116} // namespace Safir
117
118#endif
119#endif // __DOB_UTILITIES_ACE_DISPATCHER_H__
This namespace contains all the functionality and definitions of the SAFIR SDK.
Definition Backdoor.h:31
A connection to the DOB.
Definition Connection.h:46
void Dispatch() const
When the dispatch event or callback is signalled, the application MUST call this method.
Interface for reception of a dispatch order.
Definition Consumer.h:74
The class makes a thread switch and perform a dispatch on Dob connection.
Definition AceDispatcher.h:59
AceDispatcher(const Safir::Dob::Connection &connection)
Constructor.
Definition AceDispatcher.h:67
AceDispatcher(const Safir::Dob::Connection &connection, ACE_Reactor *reactor)
Constructor.
Definition AceDispatcher.h:79