".github/vscode:/vscode.git/clone" did not exist on "aa3eba8eb42cb4a49bd1475e78198734b4f5ada4"
net.h 1.13 KB
Newer Older
lishen's avatar
lishen committed
1
2
3
#pragma once

#include <stdint.h>
4
5
#include <memory>

lishen's avatar
lishen committed
6
7
#include "base.h"
#include "net_utils.h"
8
9
10
#include "net_socket/socket.h"
#include "net_ib/net_ib.h"
#include "net_socket/net_socket.h"
lishen's avatar
lishen committed
11
12
13
14
15

namespace sccl {
namespace hardware {
namespace net {

16
17
// 定义一个静态的pthread互斥锁,用于线程同步
static pthread_mutex_t netLock = PTHREAD_MUTEX_INITIALIZER;
lishen's avatar
lishen committed
18

19
20
21
22
//////////////////////////////////// 功能函数 ////////////////////////////////////
// 打印Socket信息
scclResult_t printSocketAddr(union net_socket::scclSocketAddress* sock_addr, const char* prefix);
scclResult_t printSocketInfo(struct net_socket::scclSocket* sock, const char* prefix);
lishen's avatar
lishen committed
23

24
25
26
//////////////////////////////////// 网络接口 ////////////////////////////////////
// 定义网络类型数量的常量
constexpr int scclNetTypeNum = 3;
lishen's avatar
lishen committed
27

28
29
// 定义一个内联数组,存储不同类型的sccl网络指针
inline scclNetBase* scclNets[] = {nullptr, new net_ib::scclNetIb(), new net_socket::scclNetSocket()};
lishen's avatar
lishen committed
30

31
32
// 定义初始化sccl网络的函数
scclResult_t scclNetInit(const char* netName, scclNet_t*& scclNet);
lishen's avatar
lishen committed
33
34
35
36

} // namespace net
} // namespace hardware
} // namespace sccl