Skip to content

Commit

Permalink
Move to Google code style
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickelectric committed Feb 18, 2017
1 parent bcf2009 commit c23d0fc
Show file tree
Hide file tree
Showing 272 changed files with 56,405 additions and 55,290 deletions.
8 changes: 4 additions & 4 deletions AirLib/deps/rpclib/include/rpc/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace rpc {
//! asynchronously. When the client object is created, it initiates connecting
//! to the given server asynchronically and disconnects when it is destroyed.
class client {
public:
public:
//! \brief Constructs a client.
//!
//! When a client is constructed, it initiates a connection
Expand Down Expand Up @@ -74,7 +74,7 @@ class client {
//! (which is a RPCLIB_MSGPACK::object).
template <typename... Args>
std::future<RPCLIB_MSGPACK::object_handle> async_call(std::string const &func_name,
Args... args);
Args... args);

//! \brief Sends a notification with the given name and arguments (if any).
//!
Expand All @@ -100,7 +100,7 @@ class client {
//! \brief Waits for the completion of all ongoing calls.
void wait_all_responses();

private:
private:
//! \brief Type of a promise holding a future response.
using rsp_promise = std::promise<RPCLIB_MSGPACK::object_handle>;

Expand All @@ -113,7 +113,7 @@ class client {
void post(RPCLIB_MSGPACK::sbuffer *buffer);
int get_next_call_idx();

private:
private:
static constexpr uint32_t default_buffer_size = 65535;
static constexpr double buffer_grow_factor = 1.5;
RPCLIB_DECL_PIMPL(768)
Expand Down
42 changes: 21 additions & 21 deletions AirLib/deps/rpclib/include/rpc/detail/async_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace detail {

//! \brief Common logic for classes that have a write queue with async writing.
class async_writer : public std::enable_shared_from_this<async_writer> {
public:
public:
async_writer(RPCLIB_ASIO::io_service *io,
RPCLIB_ASIO::ip::tcp::socket socket)
: socket_(std::move(socket)), write_strand_(*io), exit_(false) {}
Expand All @@ -34,26 +34,26 @@ class async_writer : public std::enable_shared_from_this<async_writer> {
RPCLIB_ASIO::async_write(
socket_, RPCLIB_ASIO::buffer(item.data(), item.size()),
write_strand_.wrap(
[this, self](std::error_code ec, std::size_t transferred) {
(void)transferred;
if (!ec) {
write_queue_.pop_front();
if (write_queue_.size() > 0) {
if (!exit_) {
do_write();
}
}
} else {
LOG_ERROR("Error while writing to socket: {}", ec);
[this, self](std::error_code ec, std::size_t transferred) {
(void)transferred;
if (!ec) {
write_queue_.pop_front();
if (write_queue_.size() > 0) {
if (!exit_) {
do_write();
}
}
} else {
LOG_ERROR("Error while writing to socket: {}", ec);
}

if (exit_) {
LOG_INFO("Closing socket");
socket_.shutdown(
RPCLIB_ASIO::ip::tcp::socket::shutdown_both);
socket_.close();
}
}));
if (exit_) {
LOG_INFO("Closing socket");
socket_.shutdown(
RPCLIB_ASIO::ip::tcp::socket::shutdown_both);
socket_.close();
}
}));
}

void write(RPCLIB_MSGPACK::sbuffer &&data) {
Expand All @@ -67,15 +67,15 @@ class async_writer : public std::enable_shared_from_this<async_writer> {

friend class rpc::client;

protected:
protected:
RPCLIB_ASIO::ip::tcp::socket socket_;
RPCLIB_ASIO::strand write_strand_;
std::atomic_bool exit_{false};
bool exited_ = false;
std::mutex m_exit_;
std::condition_variable cv_exit_;

private:
private:
std::deque<RPCLIB_MSGPACK::sbuffer> write_queue_;
RPCLIB_CREATE_LOG_CHANNEL(async_writer)
};
Expand Down
2 changes: 1 addition & 1 deletion AirLib/deps/rpclib/include/rpc/detail/call.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ decltype(auto) call(Functor f, Arg &&arg) {
template <typename Functor, typename... Args>
decltype(auto) call(Functor f, std::tuple<Args...> &args) {
return call_helper(f, std::forward<std::tuple<Args...>>(args),
std::index_sequence_for<Args...>{});
std::index_sequence_for<Args...> {});
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions AirLib/deps/rpclib/include/rpc/detail/client_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace detail {
//! doing something unexpected (e.g. calling a function that does not exist,
//! wrong number of arguments, etc.)
class client_error : public std::exception {
public:
public:
//! \brief Error codes used for signaling back to clients. These are used
//! to produce google-able error messages (since the msgpack-rpc protocol
//! does not define error handling in any more detail than sending an
Expand All @@ -30,7 +30,7 @@ class client_error : public std::exception {

const char *what() const noexcept;

private:
private:
std::string what_;
};
}
Expand Down
16 changes: 12 additions & 4 deletions AirLib/deps/rpclib/include/rpc/detail/func_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,21 @@ struct nonzero_arg {};
struct void_result {};
struct nonvoid_result {};

template <int N> struct arg_count_trait { typedef nonzero_arg type; };
template <int N> struct arg_count_trait {
typedef nonzero_arg type;
};

template <> struct arg_count_trait<0> { typedef zero_arg type; };
template <> struct arg_count_trait<0> {
typedef zero_arg type;
};

template <typename T> struct result_trait { typedef nonvoid_result type; };
template <typename T> struct result_trait {
typedef nonvoid_result type;
};

template <> struct result_trait<void> { typedef void_result type; };
template <> struct result_trait<void> {
typedef void_result type;
};
}

//! \brief Provides a small function traits implementation that
Expand Down
3 changes: 2 additions & 1 deletion AirLib/deps/rpclib/include/rpc/detail/invoke.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace detail {
template<typename T>
using invoke = typename T::type;

}}
}
}


#endif /* end of include guard: INVOKE_H_0CWMPLUE */
20 changes: 10 additions & 10 deletions AirLib/deps/rpclib/include/rpc/detail/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
namespace rpc {
namespace detail {
class logger {
public:
public:
static logger &instance() {
static logger inst;
return inst;
Expand Down Expand Up @@ -65,7 +65,7 @@ class logger {
basic_log("INFO", channel, RPCLIB_FMT::format(msg, args...));
}

private:
private:
logger() {}

#ifdef _MSC_VER
Expand All @@ -84,10 +84,10 @@ class logger {
timespec now_t = {};
clock_gettime(CLOCK_REALTIME, &now_t);
ss << std::put_time(
std::localtime(reinterpret_cast<time_t *>(&now_t.tv_sec)),
"%F %T")
std::localtime(reinterpret_cast<time_t *>(&now_t.tv_sec)),
"%F %T")
<< RPCLIB_FMT::format(
".{:03}", round(static_cast<double>(now_t.tv_nsec) / 1.0e6));
".{:03}", round(static_cast<double>(now_t.tv_nsec) / 1.0e6));
return ss.str();
}
#endif
Expand All @@ -101,7 +101,7 @@ class logger {
arg("time", now()), arg("msg", msg));
}

private:
private:
std::mutex mut_print_;
};
} /* detail */
Expand All @@ -117,10 +117,10 @@ class logger {
static constexpr const char *rpc_channel_name = #Name; \
_Pragma("GCC diagnostic pop")
#elif defined(__clang__)
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wunused-variable\"") \
static constexpr const char *rpc_channel_name = #Name; \
_Pragma("clang diagnostic pop")
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wunused-variable\"") \
static constexpr const char *rpc_channel_name = #Name; \
_Pragma("clang diagnostic pop")
#endif

RPCLIB_CREATE_LOG_CHANNEL(global)
Expand Down
2 changes: 1 addition & 1 deletion AirLib/deps/rpclib/include/rpc/detail/pimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct ptr_checker {
template <typename T, std::size_t Size, int Align = -1> class pimpl_ptr {
typename aligned_storage<Size, Align>::type data;

public:
public:
#define PIMPL_PTR_CHECK_() \
ptr_checker<T, sizeof(T), Size, Align, alignof(T)> \
rpc_ptr_checker; (void) rpc_ptr_checker;
Expand Down
4 changes: 2 additions & 2 deletions AirLib/deps/rpclib/include/rpc/detail/response.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace detail {
//! \brief Represents a response and creates a msgpack to be sent back
//! as per the msgpack-rpc spec.
class response {
public:
public:
//! \brief Creates a response that represents a normal return value.
//! \param id The sequence id (as per protocol).
//! \param result The return value to store in the response.
Expand Down Expand Up @@ -67,7 +67,7 @@ class response {
using response_type =
std::tuple<uint32_t, uint32_t, RPCLIB_MSGPACK::object, RPCLIB_MSGPACK::object>;

private:
private:
//! \brief Default constructor for responses.
response();

Expand Down
6 changes: 3 additions & 3 deletions AirLib/deps/rpclib/include/rpc/detail/server_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ class server;
namespace detail {

class server_session : public async_writer {
public:
public:
server_session(server *srv, RPCLIB_ASIO::io_service *io,
RPCLIB_ASIO::ip::tcp::socket socket,
std::shared_ptr<dispatcher> disp, bool suppress_exceptions);
void start();

void close();

private:
private:
void do_read();

private:
private:
server* parent_;
RPCLIB_ASIO::io_service *io_;
RPCLIB_ASIO::strand read_strand_;
Expand Down
8 changes: 5 additions & 3 deletions AirLib/deps/rpclib/include/rpc/detail/thread_group.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace rpc {
namespace detail {

class thread_group {
public:
public:
thread_group() {}
thread_group(thread_group const &) = delete;

Expand All @@ -28,9 +28,11 @@ class thread_group {
}
}

~thread_group() { join_all(); }
~thread_group() {
join_all();
}

private:
private:
std::vector<std::thread> threads_;
};

Expand Down
8 changes: 4 additions & 4 deletions AirLib/deps/rpclib/include/rpc/dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace detail {
//! \brief This class maintains a registry of functors associated with their
//! names, and callable using a msgpack-rpc call pack.
class dispatcher {
public:
public:
//! \brief Binds a functor to a name so it becomes callable via RPC.
//! \param name The name of the functor.
//! \param func The functor to bind.
Expand Down Expand Up @@ -82,15 +82,15 @@ class dispatcher {
//! \brief This functor type unifies the interfaces of functions that are
//! called remotely
using adaptor_type = std::function<std::unique_ptr<RPCLIB_MSGPACK::object_handle>(
RPCLIB_MSGPACK::object const &)>;
RPCLIB_MSGPACK::object const &)>;

//! \brief This is the type of messages as per the msgpack-rpc spec.
using call_t = std::tuple<int8_t, uint32_t, std::string, RPCLIB_MSGPACK::object>;

//! \brief This is the type of notification messages.
using notification_t = std::tuple<int8_t, std::string, RPCLIB_MSGPACK::object>;

private:
private:
//! \brief Checks the argument count and throws an exception if
//! it is not the expected amount.
static void enforce_arg_count(std::string const &func, std::size_t found,
Expand All @@ -108,7 +108,7 @@ class dispatcher {

enum class request_type { call = 0, notification = 2 };

private:
private:
std::unordered_map<std::string, adaptor_type> funcs_;
RPCLIB_CREATE_LOG_CHANNEL(dispatcher)
};
Expand Down
Loading

0 comments on commit c23d0fc

Please sign in to comment.