MCPcopy
hub / github.com/aceld/zinx / Poll2

Function Poll2

examples/zinx_RequestPollMode/pool_mode_server/PoolModeServer.go:26–43  ·  view source on GitHub ↗
(request ziface.IRequest)

Source from the content-addressed store, hash-verified

24}
25
26func Poll2(request ziface.IRequest) {
27 defer func() {
28 if err := recover(); err != nil {
29 // 接收一个panic
30 fmt.Println(err)
31 }
32
33 }()
34 get_conn, ok := request.Get("conn")
35 if ok {
36 // 如果直接取用则会导致空指针
37 request.GetConnection().GetConnID()
38 // 打印出的 Request 对象的地址是不一致的
39 conn := get_conn.(ziface.IConnection)
40 fmt.Printf("request copy addr:%p,conn:%p \n", &request, conn)
41 // conn.sendMsg()
42 }
43}
44
45// 如果请求的次数多,则开启对象池且直接传递不copy Request 就可能导致值不一致
46func Poll3(request ziface.IRequest) {

Callers 1

Poll1Function · 0.85

Calls 3

GetMethod · 0.65
GetConnIDMethod · 0.65
GetConnectionMethod · 0.65

Tested by

no test coverage detected