ing
This commit is contained in:
parent
a8044481d9
commit
0464cbccb3
|
@ -158,14 +158,18 @@ func (ccrn *ClientCodecResponseOrNotify) Complete() {
|
||||||
var clientRequestPool sync.Pool
|
var clientRequestPool sync.Pool
|
||||||
|
|
||||||
func retainClientRequest(method string, params interface{}, id interface{}) *clientRequest {
|
func retainClientRequest(method string, params interface{}, id interface{}) *clientRequest {
|
||||||
|
var cr *clientRequest
|
||||||
v := clientRequestPool.Get()
|
v := clientRequestPool.Get()
|
||||||
if v == nil {
|
if v == nil {
|
||||||
return &clientRequest{}
|
cr = &clientRequest{}
|
||||||
|
} else {
|
||||||
|
cr = v.(*clientRequest)
|
||||||
}
|
}
|
||||||
cr := v.(*clientRequest)
|
|
||||||
cr.Method = method
|
cr.Method = method
|
||||||
cr.Params = params
|
cr.Params = params
|
||||||
cr.ID = id
|
cr.ID = id
|
||||||
|
|
||||||
return cr
|
return cr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -226,12 +226,14 @@ type EmptyResponse struct {
|
||||||
var serverCodecRequestPool sync.Pool
|
var serverCodecRequestPool sync.Pool
|
||||||
|
|
||||||
func retainServerCodecRequest(request *serverRequest, err error, encoder encode.Encoder) *ServerCodecRequest {
|
func retainServerCodecRequest(request *serverRequest, err error, encoder encode.Encoder) *ServerCodecRequest {
|
||||||
|
var scr *ServerCodecRequest
|
||||||
v := serverCodecRequestPool.Get()
|
v := serverCodecRequestPool.Get()
|
||||||
if v == nil {
|
if v == nil {
|
||||||
return &ServerCodecRequest{}
|
scr = &ServerCodecRequest{}
|
||||||
|
} else {
|
||||||
|
scr = v.(*ServerCodecRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
scr := v.(*ServerCodecRequest)
|
|
||||||
scr.request = request
|
scr.request = request
|
||||||
scr.err = err
|
scr.err = err
|
||||||
scr.encoder = encoder
|
scr.encoder = encoder
|
||||||
|
@ -268,11 +270,14 @@ func releaseServerRequest(sr *serverRequest) {
|
||||||
var serverResponsePool sync.Pool
|
var serverResponsePool sync.Pool
|
||||||
|
|
||||||
func retainServerResponse(version string, result interface{}, err *Error, id *json.RawMessage) *serverResponse {
|
func retainServerResponse(version string, result interface{}, err *Error, id *json.RawMessage) *serverResponse {
|
||||||
|
var sr *serverResponse
|
||||||
v := serverResponsePool.Get()
|
v := serverResponsePool.Get()
|
||||||
if v == nil {
|
if v == nil {
|
||||||
return &serverResponse{}
|
sr = &serverResponse{}
|
||||||
|
} else {
|
||||||
|
sr = v.(*serverResponse)
|
||||||
}
|
}
|
||||||
sr := v.(*serverResponse)
|
|
||||||
sr.Version = version
|
sr.Version = version
|
||||||
sr.Result = result
|
sr.Result = result
|
||||||
sr.Error = err
|
sr.Error = err
|
||||||
|
|
Loading…
Reference in New Issue
Block a user