Full Mattermost server source with integrated Community Enterprise features. Includes vendor directory for offline/air-gapped builds. Structure: - enterprise-impl/: Enterprise feature implementations - enterprise-community/: Init files that register implementations - enterprise/: Bridge imports (community_imports.go) - vendor/: All dependencies for offline builds Build (online): go build ./cmd/mattermost Build (offline/air-gapped): go build -mod=vendor ./cmd/mattermost 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
37 lines
532 B
Go
37 lines
532 B
Go
package util
|
|
|
|
import (
|
|
"sync"
|
|
)
|
|
|
|
type Container interface {
|
|
Capacity() int
|
|
ResetLen(n int)
|
|
}
|
|
|
|
func NewPool[T Container](fn func(capacity int) T) *Pool[T] {
|
|
return &Pool[T]{fn: fn}
|
|
}
|
|
|
|
type Pool[T Container] struct {
|
|
sp sync.Pool
|
|
fn func(capacity int) T
|
|
}
|
|
|
|
func (p *Pool[T]) Get(length, capacity int) T {
|
|
s, ok := p.sp.Get().(T)
|
|
if !ok {
|
|
s = p.fn(capacity)
|
|
} else if s.Capacity() < capacity {
|
|
p.sp.Put(s)
|
|
s = p.fn(capacity)
|
|
}
|
|
s.ResetLen(length)
|
|
return s
|
|
}
|
|
|
|
func (p *Pool[T]) Put(s T) {
|
|
s.ResetLen(0)
|
|
p.sp.Put(s)
|
|
}
|