1// +build js 2 3package sync 4 5import "unsafe" 6 7type Pool struct { 8 local unsafe.Pointer 9 localSize uintptr 10 11 store []interface{} 12 New func() interface{} 13} 14 15func (p *Pool) Get() interface{} { 16 if len(p.store) == 0 { 17 if p.New != nil { 18 return p.New() 19 } 20 return nil 21 } 22 x := p.store[len(p.store)-1] 23 p.store = p.store[:len(p.store)-1] 24 return x 25} 26 27func (p *Pool) Put(x interface{}) { 28 if x == nil { 29 return 30 } 31 p.store = append(p.store, x) 32} 33 34func runtime_registerPoolCleanup(cleanup func()) { 35} 36