(conn ziface.IConnection, msg ziface.IMessage)
| 60 | } |
| 61 | |
| 62 | func GetRequest(conn ziface.IConnection, msg ziface.IMessage) ziface.IRequest { |
| 63 | |
| 64 | // 根据当前模式判断是否使用对象池 |
| 65 | if zconf.GlobalObject.RequestPoolMode { |
| 66 | // 从对象池中取得一个 Request 对象,如果池子中没有可用的 Request 对象则会调用 allocateRequest 函数构造一个新的对象分配 |
| 67 | r := RequestPool.Get().(*Request) |
| 68 | // 因为取出的 Request 对象可能是已存在也可能是新构造的,无论是哪种情况都应该初始化再返回使用 |
| 69 | r.Reset(conn, msg) |
| 70 | return r |
| 71 | } |
| 72 | return NewRequest(conn, msg) |
| 73 | } |
| 74 | |
| 75 | func PutRequest(request ziface.IRequest) { |
| 76 | // 判断是否开启了对象池模式 |
no test coverage detected