From 38a0ebdbab43e232a00835eb345e8419696b0252 Mon Sep 17 00:00:00 2001 From: liuyuecai Date: Sat, 16 Nov 2024 18:00:58 +0800 Subject: [PATCH] fix format --- src/net/callback_function.h | 3 ++- src/net/event_server.h | 6 ++---- src/net/thread_manager.h | 13 ++++--------- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/net/callback_function.h b/src/net/callback_function.h index 458e4bb..57bf086 100644 --- a/src/net/callback_function.h +++ b/src/net/callback_function.h @@ -35,7 +35,8 @@ concept HasSetFdFunction = requires(T t, uint64_t id, int8_t index) { { (*t).GetConnId() } -> std::same_as; // GetFd return type is int { (*t).SetThreadIndex(index) } -> std::same_as; // SetThreadIndex return type is void { (*t).GetThreadIndex() } -> std::same_as; // GetThreadIndex return type is int8_t -} || std::is_class_v; // If T is an ordinary class, the member function is called directly +} +|| std::is_class_v; // If T is an ordinary class, the member function is called directly template requires HasSetFdFunction diff --git a/src/net/event_server.h b/src/net/event_server.h index dbaafb5..6eafd18 100644 --- a/src/net/event_server.h +++ b/src/net/event_server.h @@ -104,8 +104,7 @@ class EventServer final { }; template -requires HasSetFdFunction -std::pair EventServer::StartServer(int64_t interval) { +requires HasSetFdFunction std::pair EventServer::StartServer(int64_t interval) { if (threadNum_ <= 0) { return std::pair(false, "thread num must be greater than 0"); } @@ -144,8 +143,7 @@ std::pair EventServer::StartServer(int64_t interval) { } template -requires HasSetFdFunction -std::pair EventServer::StartClientServer() { +requires HasSetFdFunction std::pair EventServer::StartClientServer() { if (threadNum_ <= 0) { return std::pair(false, "thread num must be greater than 0"); } diff --git a/src/net/thread_manager.h b/src/net/thread_manager.h index c202ab4..a7c819e 100644 --- a/src/net/thread_manager.h +++ b/src/net/thread_manager.h @@ -114,10 +114,7 @@ class ThreadManager { }; template -requires HasSetFdFunction -ThreadManager::~ThreadManager() { - Stop(); -} +requires HasSetFdFunction ThreadManager::~ThreadManager() { Stop(); } template requires HasSetFdFunction @@ -204,9 +201,7 @@ void ThreadManager::OnNetEventClose(uint64_t connId, std::string &&err) { template requires HasSetFdFunction -void ThreadManager::CloseConnection(uint64_t connId) { - OnNetEventClose(connId, ""); -} +void ThreadManager::CloseConnection(uint64_t connId) { OnNetEventClose(connId, ""); } template requires HasSetFdFunction @@ -331,8 +326,8 @@ bool ThreadManager::CreateWriteThread() { } template -requires HasSetFdFunction -uint64_t ThreadManager::DoTCPConnect(T &t, int fd, const std::shared_ptr &conn) { +requires HasSetFdFunction uint64_t ThreadManager::DoTCPConnect(T &t, int fd, + const std::shared_ptr &conn) { auto connId = getConnId(); if constexpr (IsPointer_v) { t->SetConnId(connId);