SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
ReadSync.h
Go to the documentation of this file.
1 /*
2  * SWC-DB© Copyright since 2019 Alex Kashirin <kashirin.alex@gmail.com>
3  * License details at <https://github.com/kashirin-alex/swc-db/#license>
4  */
5 
6 #ifndef swcdb_fs_Broker_Protocol_req_ReadSync_h
7 #define swcdb_fs_Broker_Protocol_req_ReadSync_h
8 
11 
12 
13 namespace SWC { namespace Comm { namespace Protocol {
14 namespace FsBroker { namespace Req {
15 
16 
17 class ReadSync final : public BaseSync, public Base {
18  public:
19  typedef std::shared_ptr<ReadSync> Ptr;
20 
21  void* buffer;
22  bool allocated;
23  size_t amount;
24 
27  uint32_t timeout, FS::SmartFd::Ptr& a_smartfd,
28  void* dst, size_t len, bool a_allocated)
29  : Base(
30  stats, FS::Statistics::READ_SYNC,
31  Buffers::make(
32  Params::ReadReq(a_smartfd->fd(), len),
33  0,
34  FUNCTION_READ, timeout
35  )
36  ),
37  buffer(dst), allocated(a_allocated), amount(0),
38  smartfd(a_smartfd) {
39  }
40 
41  ReadSync(ReadSync&&) = delete;
42  ReadSync(const ReadSync&) = delete;
43  ReadSync& operator=(ReadSync&&) = delete;
44  ReadSync& operator=(const ReadSync&) = delete;
45 
46  ~ReadSync() noexcept { }
47 
48  void handle(ConnHandlerPtr, const Event::Ptr& ev) override {
50  if(amount) {
51  if(allocated) {
52  memcpy(buffer, ev->data_ext.base, amount);
53  } else {
54  static_cast<StaticBuffer*>(buffer)->set(ev->data_ext);
55  }
56  }
58  }
59 
60  private:
62 
63 };
64 
65 
66 }}}}}
67 
68 
69 #endif // swcdb_fs_Broker_Protocol_req_ReadSync_h
SWC::Comm::Protocol::FsBroker::Req::ReadSync::smartfd
FS::SmartFd::Ptr & smartfd
Definition: ReadSync.h:61
SWC::Comm::Protocol::FsBroker::Req::ReadSync::allocated
bool allocated
Definition: ReadSync.h:22
SWC::Comm::Protocol::FsBroker::Req::BaseSync
Definition: BaseSync.h:17
Read.h
Base.h
SWC::Comm::Protocol::FsBroker::Req::ReadSync::ReadSync
SWC_CAN_INLINE ReadSync(FS::Statistics &stats, uint32_t timeout, FS::SmartFd::Ptr &a_smartfd, void *dst, size_t len, bool a_allocated)
Definition: ReadSync.h:26
SWC::Comm::Protocol::FsBroker::Req::ReadSync::buffer
void * buffer
Definition: ReadSync.h:21
SWC::Comm::Protocol::FsBroker::FUNCTION_READ
@ FUNCTION_READ
Read.
Definition: Commands.h:30
SWC::Comm::Protocol::FsBroker::Req::ReadSync::ReadSync
ReadSync(const ReadSync &)=delete
SWC_CAN_INLINE
#define SWC_CAN_INLINE
Definition: Compat.h:102
SWC::Comm::Protocol::FsBroker::Req::Base::handle_read
void handle_read(const Event::Ptr &ev, FS::SmartFd::Ptr &smartfd, size_t &amount)
Definition: Base.cc:163
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::Comm::Protocol::FsBroker::Req::ReadSync::handle
void handle(ConnHandlerPtr, const Event::Ptr &ev) override
Definition: ReadSync.h:48
SWC::Comm::Protocol::FsBroker::Req::ReadSync::operator=
ReadSync & operator=(ReadSync &&)=delete
SWC::Core::Buffer
Definition: Buffer.h:18
SWC::Comm::Protocol::FsBroker::Req::ReadSync::operator=
ReadSync & operator=(const ReadSync &)=delete
SWC::Comm::Protocol::FsBroker::Req::ReadSync::ReadSync
ReadSync(ReadSync &&)=delete
SWC::Comm::Buffers
Definition: Buffers.h:20
SWC::Comm::ConnHandlerPtr
std::shared_ptr< ConnHandler > ConnHandlerPtr
Definition: AppContext.h:17
SWC::Comm::Protocol::FsBroker::Req::ReadSync::~ReadSync
~ReadSync() noexcept
Definition: ReadSync.h:46
set
void set(uint64_t cmd=0, uint32_t timeout=0) noexcept
Definition: Header.h:33
SWC::FS::SmartFd::Ptr
std::shared_ptr< SmartFd > Ptr
Definition: SmartFd.h:37
SWC::FS::Statistics
Definition: Statistics.h:18
SWC::Comm::Protocol::FsBroker::Req::ReadSync::Ptr
std::shared_ptr< ReadSync > Ptr
Definition: ReadSync.h:19
SWC::Core::StateSynchronization::acknowledge
SWC_CAN_INLINE void acknowledge() noexcept
Definition: StateSynchronization.h:31
SWC::Comm::Event::Ptr
std::shared_ptr< Event > Ptr
Definition: Event.h:33
SWC::Comm::Protocol::FsBroker::Req::ReadSync
Definition: ReadSync.h:17
SWC::Comm::Protocol::FsBroker::Req::ReadSync::amount
size_t amount
Definition: ReadSync.h:23
SWC::Comm::Protocol::FsBroker::Req::Base
Definition: Base.h:17