mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-12-23 18:52:11 +00:00
24 lines
416 B
Go
24 lines
416 B
Go
package simple
|
|
|
|
import "sync"
|
|
|
|
// entryPool is a global pool for Entry
|
|
// objects, regardless of cache type.
|
|
var entryPool sync.Pool
|
|
|
|
// GetEntry fetches an Entry from pool, or allocates new.
|
|
func GetEntry() *Entry {
|
|
v := entryPool.Get()
|
|
if v == nil {
|
|
return new(Entry)
|
|
}
|
|
return v.(*Entry)
|
|
}
|
|
|
|
// PutEntry replaces an Entry in the pool.
|
|
func PutEntry(e *Entry) {
|
|
e.Key = nil
|
|
e.Value = nil
|
|
entryPool.Put(e)
|
|
}
|