Skip to content

Commit

Permalink
fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyuecai committed Nov 16, 2024
1 parent 5bd94d3 commit 38a0ebd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/net/callback_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ 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
6 changes: 2 additions & 4 deletions src/net/event_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ 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 @@ -144,8 +143,7 @@ std::pair<bool, std::string> EventServer<T>::StartServer(int64_t interval) {
}

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
13 changes: 4 additions & 9 deletions src/net/thread_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,7 @@ 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 @@ -204,9 +201,7 @@ 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 @@ -331,8 +326,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

0 comments on commit 38a0ebd

Please sign in to comment.