From 6eefba812ede29549af3633c490f2e85a4805524 Mon Sep 17 00:00:00 2001 From: lichao <lichao@aiotlink.com> Date: 星期三, 31 三月 2021 11:24:20 +0800 Subject: [PATCH] format code style. --- src/socket.h | 75 +++++++++++++++++++------------------ 1 files changed, 38 insertions(+), 37 deletions(-) diff --git a/src/socket.h b/src/socket.h index e65ac83..92c1b73 100644 --- a/src/socket.h +++ b/src/socket.h @@ -20,55 +20,56 @@ #define SOCKET_GWTJHBPO #include "shm_queue.h" -#include <vector> -#include <thread> -#include <memory> -#include <functional> -#include <mutex> -#include <condition_variable> #include <atomic> +#include <condition_variable> +#include <functional> +#include <memory> +#include <mutex> +#include <thread> +#include <vector> class ShmSocket { - typedef bhome_shm::ShmMsgQueue Queue; + typedef bhome_shm::ShmMsgQueue Queue; + public: - enum Type { - eSockRequest, - eSockReply, - eSockSubscribe, - eSockPublish, - }; - typedef std::function<void (bhome_msg::BHMsg &msg)> RecvCB; + enum Type { + eSockRequest, + eSockReply, + eSockSubscribe, + eSockPublish, + }; + typedef std::function<void(bhome_msg::BHMsg &msg)> RecvCB; - ShmSocket(Type type); - ShmSocket(Type type, bhome_shm::SharedMemory &shm); - ~ShmSocket(); + ShmSocket(Type type); + ShmSocket(Type type, bhome_shm::SharedMemory &shm); + ~ShmSocket(); - // bool Request(const std::string &topic, const void *data, const size_t size, onReply); - bool RequestAndWait() { return false; } // call Request, and wait onReply notify cv + // bool Request(const std::string &topic, const void *data, const size_t size, onReply); + bool RequestAndWait() { return false; } // call Request, and wait onReply notify cv - // bool HandleRequest(onData); - bool ReadRequest(); // exclude with HandleRequest - bool SendReply(); // exclude with HandleRequest + // bool HandleRequest(onData); + bool ReadRequest(); // exclude with HandleRequest + bool SendReply(); // exclude with HandleRequest - bool Publish(const std::string &topic, const void *data, const size_t size, const int timeout_ms); - bool Subscribe(const std::vector<std::string> &topics, const int timeout_ms); - bool RecvSub(std::string &topic, std::string &data, const int timeout_ms); - bool SetRecvCallback(const RecvCB &onRecv); + bool Publish(const std::string &topic, const void *data, const size_t size, const int timeout_ms); + bool Subscribe(const std::vector<std::string> &topics, const int timeout_ms); + bool RecvSub(std::string &topic, std::string &data, const int timeout_ms); + bool SetRecvCallback(const RecvCB &onRecv); + private: - bool HasRecvCB(); - void Stop(); + bool HasRecvCB(); + void Stop(); - bhome_shm::SharedMemory &shm_; - Type type_; - std::vector<std::thread> workers_; - std::mutex mutex_; - std::condition_variable cv_recv_cb_; - std::atomic<bool> run_; - RecvCB onRecv_; + bhome_shm::SharedMemory &shm_; + Type type_; + std::vector<std::thread> workers_; + std::mutex mutex_; + std::condition_variable cv_recv_cb_; + std::atomic<bool> run_; + RecvCB onRecv_; - std::unique_ptr<Queue> mq_; + std::unique_ptr<Queue> mq_; }; - #endif // end of include guard: SOCKET_GWTJHBPO -- Gitblit v1.8.0