Skip to content

Commit

Permalink
clang18 format code
Browse files Browse the repository at this point in the history
  • Loading branch information
hahahashen committed Oct 12, 2024
1 parent 10e5ad9 commit f83bc90
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/cmd_admin.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CmdConfig : public BaseCmdGroup {
private:
// std::vector<std::string> subCmd_;

void DoCmd(PClient* client) override{};
void DoCmd(PClient* client) override {};
};

class CmdConfigGet : public BaseCmd {
Expand Down Expand Up @@ -178,7 +178,7 @@ class CmdDebug : public BaseCmdGroup {
bool DoInitial(PClient* client) override { return true; };

private:
void DoCmd(PClient* client) override{};
void DoCmd(PClient* client) override {};
};

class CmdDebugHelp : public BaseCmd {
Expand Down
2 changes: 1 addition & 1 deletion src/net/base_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class BaseEvent : public std::enable_shared_from_this<BaseEvent> {
const static int EVENT_HUB;

BaseEvent(const std::shared_ptr<NetEvent> &listen, int8_t mode, int8_t type)
: listen_(listen), mode_(mode), type_(type){};
: listen_(listen), mode_(mode), type_(type) {};

virtual ~BaseEvent() = default;

Expand Down
2 changes: 1 addition & 1 deletion src/net/base_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class BaseSocket : public NetEvent {

~BaseSocket() override = default;

void OnError() override{};
void OnError() override {};

void Close() override;

Expand Down
3 changes: 1 addition & 2 deletions src/net/callback_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ concept HasSetFdFunction = requires(T t, uint64_t id, int8_t index) {
{ (*t).GetConnId() } -> std::same_as<uint64_t>; // GetFd return type is int
{ (*t).SetThreadIndex(index) } -> std::same_as<void>; // SetThreadIndex return type is void
{ (*t).GetThreadIndex() } -> std::same_as<int8_t>; // GetThreadIndex return type is int8_t
}
|| std::is_class_v<T>; // If T is an ordinary class, the member function is called directly
} || std::is_class_v<T>; // If T is an ordinary class, the member function is called directly

template <typename T>
requires HasSetFdFunction<T>
Expand Down
2 changes: 1 addition & 1 deletion src/net/client_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace net {

class ClientSocket : public StreamSocket {
public:
explicit ClientSocket(const SocketAddr& addr) : StreamSocket(0, SOCKET_TCP), addr_(addr){};
explicit ClientSocket(const SocketAddr& addr) : StreamSocket(0, SOCKET_TCP), addr_(addr) {};

~ClientSocket() override = default;

Expand Down
2 changes: 1 addition & 1 deletion src/net/epoll_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace net {
class EpollEvent : public BaseEvent {
public:
explicit EpollEvent(const std::shared_ptr<NetEvent> &listen, int8_t mode)
: BaseEvent(listen, mode, BaseEvent::EVENT_TYPE_EPOLL){};
: BaseEvent(listen, mode, BaseEvent::EVENT_TYPE_EPOLL) {};

~EpollEvent() override { Close(); }

Expand Down
6 changes: 4 additions & 2 deletions src/net/event_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ class EventServer final {
};

template <typename T>
requires HasSetFdFunction<T> std::pair<bool, std::string> EventServer<T>::StartServer(int64_t interval) {
requires HasSetFdFunction<T>
std::pair<bool, std::string> EventServer<T>::StartServer(int64_t interval) {
if (threadNum_ <= 0) {
return std::pair(false, "thread num must be greater than 0");
}
Expand Down Expand Up @@ -143,7 +144,8 @@ requires HasSetFdFunction<T> std::pair<bool, std::string> EventServer<T>::StartS
}

template <typename T>
requires HasSetFdFunction<T> std::pair<bool, std::string> EventServer<T>::StartClientServer() {
requires HasSetFdFunction<T>
std::pair<bool, std::string> EventServer<T>::StartClientServer() {
if (threadNum_ <= 0) {
return std::pair(false, "thread num must be greater than 0");
}
Expand Down
2 changes: 1 addition & 1 deletion src/net/io_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace net {

class IOThread {
public:
explicit IOThread(const std::shared_ptr<BaseEvent> &event) : baseEvent_(event){};
explicit IOThread(const std::shared_ptr<BaseEvent> &event) : baseEvent_(event) {};

~IOThread() = default;

Expand Down
2 changes: 1 addition & 1 deletion src/net/kqueue_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace net {
class KqueueEvent : public BaseEvent {
public:
explicit KqueueEvent(std::shared_ptr<NetEvent> listen, int8_t mode)
: BaseEvent(std::move(listen), mode, BaseEvent::EVENT_TYPE_KQUEUE){};
: BaseEvent(std::move(listen), mode, BaseEvent::EVENT_TYPE_KQUEUE) {};

~KqueueEvent() override { Close(); }

Expand Down
13 changes: 9 additions & 4 deletions src/net/thread_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ class ThreadManager {
};

template <typename T>
requires HasSetFdFunction<T> ThreadManager<T>::~ThreadManager() { Stop(); }
requires HasSetFdFunction<T>
ThreadManager<T>::~ThreadManager() {
Stop();
}

template <typename T>
requires HasSetFdFunction<T>
Expand Down Expand Up @@ -201,7 +204,9 @@ void ThreadManager<T>::OnNetEventClose(uint64_t connId, std::string &&err) {

template <typename T>
requires HasSetFdFunction<T>
void ThreadManager<T>::CloseConnection(uint64_t connId) { OnNetEventClose(connId, ""); }
void ThreadManager<T>::CloseConnection(uint64_t connId) {
OnNetEventClose(connId, "");
}

template <typename T>
requires HasSetFdFunction<T>
Expand Down Expand Up @@ -326,8 +331,8 @@ bool ThreadManager<T>::CreateWriteThread() {
}

template <typename T>
requires HasSetFdFunction<T> uint64_t ThreadManager<T>::DoTCPConnect(T &t, int fd,
const std::shared_ptr<Connection> &conn) {
requires HasSetFdFunction<T>
uint64_t ThreadManager<T>::DoTCPConnect(T &t, int fd, const std::shared_ptr<Connection> &conn) {
auto connId = getConnId();
if constexpr (IsPointer_v<T>) {
t->SetConnId(connId);
Expand Down
2 changes: 1 addition & 1 deletion src/storage/src/base_data_value_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class ParsedBaseDataValue : public ParsedInternalValue {
}

protected:
virtual void SetVersionToValue() override{};
virtual void SetVersionToValue() override {};

private:
const size_t kBaseDataValueSuffixLength = kSuffixReserveLength + kTimestampLength;
Expand Down

0 comments on commit f83bc90

Please sign in to comment.