Rpc内存优化

This commit is contained in:
boyce
2020-12-21 15:04:32 +08:00
parent 7586221b80
commit 4be0e7428d

View File

@@ -49,6 +49,7 @@ type RpcHandler struct {
callRequest chan *RpcRequest callRequest chan *RpcRequest
rpcHandler IRpcHandler rpcHandler IRpcHandler
mapFunctions map[string]RpcMethodInfo mapFunctions map[string]RpcMethodInfo
mapRawFunctions map[int]
funcRpcClient FuncRpcClient funcRpcClient FuncRpcClient
funcRpcServer FuncRpcServer funcRpcServer FuncRpcServer
@@ -257,9 +258,7 @@ func (handler *RpcHandler) HandlerRpcRequest(request *RpcRequest) {
var err error var err error
var iParam interface{} var iParam interface{}
//单协程或非异步调用时直接使用预置对象 //单协程或非异步调用时直接使用预置对象
if handler.IsSingleCoroutine() && v.hasResponder==false { if v.inParam!= nil {
iParam = v.inParam
}else if v.inParam != nil {
iParam = reflect.New(v.inParamValue.Type().Elem()).Interface() iParam = reflect.New(v.inParamValue.Type().Elem()).Interface()
} }
@@ -311,8 +310,6 @@ func (handler *RpcHandler) HandlerRpcRequest(request *RpcRequest) {
if v.outParamValue.IsValid() { if v.outParamValue.IsValid() {
if request.localReply!=nil { if request.localReply!=nil {
oParam = reflect.ValueOf(request.localReply) //输出参数 oParam = reflect.ValueOf(request.localReply) //输出参数
}else if handler.IsSingleCoroutine()==true{
oParam = v.outParamValue
}else{ }else{
oParam = reflect.New(v.outParamValue.Type().Elem()) oParam = reflect.New(v.outParamValue.Type().Elem())
} }