0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
TableMutatorIntervalHandler.h
Go to the documentation of this file.
1 /* -*- c++ -*-
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 Hypertable. If not, see <http://www.gnu.org/licenses/>
18  */
19 
26 #ifndef Hypertable_Lib_TableMutatorIntervalHandler_h
27 #define Hypertable_Lib_TableMutatorIntervalHandler_h
28 
30 
31 #include <condition_variable>
32 #include <mutex>
33 
34 namespace Hypertable {
35 
36  class Comm;
37  class TableMutatorShared;
38 
52  public:
53 
68 
70  void start();
71 
81  virtual void handle(EventPtr &event);
82 
89  void flush();
90 
95  void stop() {
96  std::unique_lock<std::mutex> lock(mutex);
97  active = false;
98  cond.wait(lock, [this](){ return complete; });
99  }
100 
101  private:
102 
105 
107  std::condition_variable cond;
108 
110  bool active;
111 
113  bool complete;
114 
117 
120 
123  };
124 
126  typedef std::shared_ptr<TableMutatorIntervalHandler>
128 
131 }
132 
133 #endif
static std::mutex mutex
Definition: Logger.cc:43
Timer handler for periodically flushing a shared mutator.
virtual void handle(EventPtr &event)
Handles the timer interrupt.
bool active
Set to false to deactivate and prevent further timer interrupts.
Abstract base class for application dispatch handlers registered with AsyncComm.
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
Definition: Event.h:228
Comm * comm
Pointer to AsyncComm subsystem.
std::mutex mutex
Mutex for serializing access to members
void stop()
Stops the periodic flushing of the shared mutator.
Declarations for DispatchHandler.
std::condition_variable cond
Condition variable signalled when complete is set to true
TableMutatorIntervalHandler(Comm *comm, ApplicationQueueInterface *app_queue, TableMutatorShared *shared_mutator)
Constructor.
Hypertable definitions
TableMutatorShared * shared_mutator
Shared mutator to be periodically flushed.
bool complete
Indicates if final timer interrupt has completed.
Entry point to AsyncComm service.
Definition: Comm.h:61
void flush()
Flushes shared mutator shared_mutator.
A TableMutator that can be shared from multiple threads and incidentally has an option to do periodic...
Abstract interface for application queue.
ApplicationQueueInterface * app_queue
Pointer to application queue.
std::shared_ptr< TableMutatorIntervalHandler > TableMutatorIntervalHandlerPtr
Smart pointer to TableMutatorIntervalHandler.