25 #ifndef INCLUDED_AsyncAccessControl_h_GUID_4255BCEE_826C_4DB4_9368_9457ADBF9456
26 #define INCLUDED_AsyncAccessControl_h_GUID_4255BCEE_826C_4DB4_9368_9457ADBF9456
32 #include <boost/noncopyable.hpp>
33 #include <boost/thread.hpp>
34 #include <boost/optional/optional.hpp>
40 namespace connection {
74 enum MainThreadMessages {
81 typedef boost::recursive_mutex MainMutexType;
82 typedef boost::unique_lock<MainMutexType> MainLockType;
96 bool m_handleRTS(MainLockType &lock, MainThreadMessages response,
97 MainThreadMessages postCompletionState = MTM_WAIT);
101 typedef boost::mutex DoneMutexType;
102 typedef boost::unique_lock<DoneMutexType> DoneLockType;
103 DoneMutexType m_mutDone;
105 boost::optional<boost::thread::id> m_currentRequestThread;
109 boost::condition_variable m_condMainThread;
112 boost::condition_variable_any m_condAsyncThread;
117 volatile bool m_done;
119 volatile MainThreadMessages m_mainMessage;
154 AsyncAccessControl::MainLockType m_lock;
157 AsyncAccessControl::DoneLockType m_lockDone;
160 bool m_calledRequest;
168 volatile bool &m_sharedRts;
169 volatile bool &m_sharedDone;
170 volatile AsyncAccessControl::MainThreadMessages &m_mainMessage;
172 boost::condition_variable &m_condMainThread;
173 boost::condition_variable_any &m_condAsyncThread;
179 #endif // INCLUDED_AsyncAccessControl_h_GUID_4255BCEE_826C_4DB4_9368_9457ADBF9456
bool isNested() const
Method to find out if this is a nested RTS - primarily for testing.
RAII object for use by an async thread to manage a request to send.
~RequestToSend()
Destructor.
bool mainThreadDenyPermanently()
Permanently deny present and future requests.
bool mainThreadDeny()
Check for waiting async thread, and deny it permission to send if found.
Internal class handling the synchronization of an asynchronous thread wishing to communicate that has...
bool request()
Issues a blocking request to send.
RequestToSend(AsyncAccessControl &aac)
Creates an RAII object to manage the request to send - note that it does not immediately request to s...
AsyncAccessControl()
Constructor.