0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ClientBufferedReaderHandler.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 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 #ifndef FsBroker_Lib_ClientBufferedReaderHandler_h
22 #define FsBroker_Lib_ClientBufferedReaderHandler_h
23 
25 
26 #include <Common/String.h>
27 
28 #include <condition_variable>
29 #include <mutex>
30 #include <queue>
31 
32 namespace Hypertable {
33 namespace FsBroker {
34 namespace Lib {
35 
36  class Client;
37 
40 
42 
43  public:
44  ClientBufferedReaderHandler(Client *client, uint32_t fd,
45  uint32_t buf_size, uint32_t outstanding, uint64_t start_offset,
46  uint64_t end_offset);
47 
49 
50  virtual void handle(EventPtr &event);
51 
52  size_t read(void *buf, size_t len);
53 
54  private:
55 
56  void read_ahead();
57 
59  std::condition_variable m_cond;
60  std::queue<EventPtr> m_queue;
62  uint32_t m_fd;
64  uint32_t m_read_size;
65  uint32_t m_outstanding;
66  bool m_eof;
67  int m_error;
68  std::string m_error_msg;
69  const uint8_t *m_ptr;
70  const uint8_t *m_end_ptr;
71  uint64_t m_end_offset;
73  uint64_t m_actual_offset;
74  };
75 
77 
78 }}}
79 
80 #endif // FsBroker_Lib_ClientBufferedReaderHandler_h
81 
static std::mutex mutex
Definition: Logger.cc:43
Abstract base class for application dispatch handlers registered with AsyncComm.
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
Definition: Event.h:228
Declarations for DispatchHandler.
ClientBufferedReaderHandler(Client *client, uint32_t fd, uint32_t buf_size, uint32_t outstanding, uint64_t start_offset, uint64_t end_offset)
Hypertable definitions
virtual void handle(EventPtr &event)
Callback method.
A String class based on std::string.
Proxy class for FS broker.
Definition: Client.h:58