2020-02-23 11:35:47 +00:00
|
|
|
package netstorage
|
|
|
|
|
|
|
|
import (
|
|
|
|
"sync"
|
|
|
|
)
|
|
|
|
|
|
|
|
// GetInsertCtx returns InsertCtx from the pool.
|
|
|
|
//
|
|
|
|
// Call PutInsertCtx for returning it to the pool.
|
|
|
|
func GetInsertCtx() *InsertCtx {
|
2024-04-20 18:38:20 +00:00
|
|
|
if v := insertCtxPool.Get(); v != nil {
|
|
|
|
return v.(*InsertCtx)
|
2020-02-23 11:35:47 +00:00
|
|
|
}
|
2024-04-20 18:38:20 +00:00
|
|
|
return &InsertCtx{}
|
2020-02-23 11:35:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// PutInsertCtx returns ctx to the pool.
|
|
|
|
//
|
|
|
|
// ctx cannot be used after the call.
|
|
|
|
func PutInsertCtx(ctx *InsertCtx) {
|
|
|
|
ctx.Reset()
|
2024-04-20 18:38:20 +00:00
|
|
|
insertCtxPool.Put(ctx)
|
2020-02-23 11:35:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var insertCtxPool sync.Pool
|