0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
DispatchHandlerSynchronizer.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
28 #ifndef AsyncComm_DispatchHandlerSynchronizer_h
29 #define AsyncComm_DispatchHandlerSynchronizer_h
30 
31 #include "DispatchHandler.h"
32 #include "Event.h"
33 
34 #include <condition_variable>
35 #include <memory>
36 #include <mutex>
37 #include <queue>
38 
39 namespace Hypertable {
40 
71 
72  public:
76 
78  }
79 
87  virtual void handle(EventPtr &event);
88 
101  bool wait_for_reply(EventPtr &event);
102 
111  bool wait_for_connection();
112 
113  private:
114 
117 
119  std::condition_variable m_cond;
120 
122  std::queue<EventPtr> m_receive_queue;
123 
124  };
125 
127  typedef std::shared_ptr<DispatchHandlerSynchronizer> DispatchHandlerSynchronizerPtr;
128 
130 }
131 
132 
133 #endif // AsyncComm_DispatchHandlerSynchronizer_h
static std::mutex mutex
Definition: Logger.cc:43
std::condition_variable m_cond
Condition variable for signalling change in queue state.
virtual void handle(EventPtr &event)
Event Dispatch method.
Abstract base class for application dispatch handlers registered with AsyncComm.
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
Definition: Event.h:228
bool wait_for_reply(EventPtr &event)
This method is used by a client to synchronize.
Declarations for Event.
std::shared_ptr< DispatchHandlerSynchronizer > DispatchHandlerSynchronizerPtr
Shared smart pointer to DispatchHandlerSynchronizer.
Declarations for DispatchHandler.
std::mutex m_mutex
Mutex for serializing concurrent access.
Hypertable definitions
DispatchHandler class used to synchronize with response messages.
std::queue< EventPtr > m_receive_queue
Event queue.
bool wait_for_connection()
Waits for CONNECTION_ESTABLISHED event.