mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-03 22:45:13 +08:00
rpc内存池优化
This commit is contained in:
@@ -144,7 +144,7 @@ func (call *Call) Done() *Call{
|
||||
}
|
||||
|
||||
func MakeRpcRequest(rpcProcessor IRpcProcessor,seq uint64,rpcMethodId uint32,serviceMethod string,noReply bool,inParam []byte) *RpcRequest{
|
||||
rpcRequest := rpcRequestPool.Get().(*RpcRequest).Clear()
|
||||
rpcRequest := rpcRequestPool.Get().(*RpcRequest)
|
||||
rpcRequest.rpcProcessor = rpcProcessor
|
||||
rpcRequest.RpcRequestData = rpcRequest.rpcProcessor.MakeRpcRequest(seq,rpcMethodId,serviceMethod,noReply,inParam)
|
||||
|
||||
|
||||
@@ -243,11 +243,11 @@ func (handler *RpcHandler) HandlerRpcRequest(request *RpcRequest) {
|
||||
request.requestHandle(nil,rpcErr)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
if request.requestHandle == nil {
|
||||
ReleaseRpcRequest(request)
|
||||
defer ReleaseRpcRequest(request)
|
||||
}
|
||||
}()
|
||||
|
||||
//如果是原始RPC请求
|
||||
rawRpcId := request.RpcRequestData.GetRpcMethodId()
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package sync
|
||||
|
||||
import sysSync "sync"
|
||||
import (
|
||||
sysSync "sync"
|
||||
)
|
||||
|
||||
type Pool struct {
|
||||
C chan interface{} //最大缓存的数量
|
||||
@@ -36,6 +38,7 @@ func (pool *Pool) Put(data interface{}){
|
||||
default:
|
||||
pool.syncPool.Put(data)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func NewPool(C chan interface{},New func()interface{}) *Pool{
|
||||
|
||||
Reference in New Issue
Block a user