mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-03 22:45:13 +08:00
优化rpc超时-使用时间轮定时器
This commit is contained in:
14
rpc/rpc.go
14
rpc/rpc.go
@@ -22,7 +22,7 @@ type RpcResponse struct {
|
||||
RpcResponseData IRpcResponseData
|
||||
}
|
||||
|
||||
var rpcResponsePool sync.Pool
|
||||
//var rpcResponsePool sync.Pool
|
||||
var rpcRequestPool sync.Pool
|
||||
var rpcCallPool sync.Pool
|
||||
|
||||
@@ -67,10 +67,6 @@ type Call struct {
|
||||
}
|
||||
|
||||
func init(){
|
||||
rpcResponsePool.New = func()interface{}{
|
||||
return &RpcResponse{}
|
||||
}
|
||||
|
||||
rpcRequestPool.New = func() interface{} {
|
||||
return &RpcRequest{}
|
||||
}
|
||||
@@ -111,10 +107,6 @@ func (call *Call) Done() *Call{
|
||||
return <-call.done
|
||||
}
|
||||
|
||||
func MakeRpcResponse() *RpcResponse{
|
||||
return rpcResponsePool.Get().(*RpcResponse).Clear()
|
||||
}
|
||||
|
||||
func MakeRpcRequest() *RpcRequest{
|
||||
return rpcRequestPool.Get().(*RpcRequest).Clear()
|
||||
}
|
||||
@@ -123,10 +115,6 @@ func MakeCall() *Call {
|
||||
return rpcCallPool.Get().(*Call).Clear()
|
||||
}
|
||||
|
||||
func ReleaseRpcResponse(rpcResponse *RpcResponse){
|
||||
rpcResponsePool.Put(rpcResponse)
|
||||
}
|
||||
|
||||
func ReleaseRpcRequest(rpcRequest *RpcRequest){
|
||||
rpcRequestPool.Put(rpcRequest)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user