func (p *Pool) Close() error {
	return p.alloc.close()
}
Close prefents future Get's from the pool and munmap's allocated memory.
Caller must ensure that all users of the pool exited before calling Close.
Otherwise program will crash referencing to an invalid memory region.
package fixed
import (
	"runtime"
	"sync"
	"sync/atomic"
	"syscall"
	"unsafe"
)
type BufferRegistry interface {
	RegisterBuffers([]syscall.Iovec) error
}
var bufferPool = sync.Pool{
	New: func() interface{} {
		return &Buffer{}
	},
}
func New(reg BufferRegistry, bufsize, size int) (*Pool, error) {
	alloc := &allocator{
		max:        size,
		bufferSize: bufsize,
		reg:        reg,
	}
	if err := alloc.init(); err != nil {
		return nil, err
	}
	var (
		head *node
	)
	for i := size - 1; i >= 0; i-- {
		head = &node{
			next:  head,
			index: i,
		}
	}
	return &Pool{
		alloc: alloc,
		head:  head,
	}, nil
}
type Pool struct {
	alloc *allocator
	head  *node
}
func (p *Pool) Get() *Buffer {
	for {
		old := (*node)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(&p.head))))
		if old != nil {
			index := old.index
			next := old.next
			if atomic.CompareAndSwapPointer((*unsafe.Pointer)(unsafe.Pointer(&p.head)), unsafe.Pointer(old), unsafe.Pointer(next)) {
				buf := bufferPool.Get().(*Buffer)
				buf.B = p.alloc.bufAt(index)
				buf.poolIndex = index
				buf.index = 0  
				return buf
			}
		}
		runtime.Gosched()
	}
}
func (p *Pool) Put(b *Buffer) {
	next := &node{index: b.poolIndex}
	for {
		head := (*node)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(&p.head))))
		next.next = head
		if atomic.CompareAndSwapPointer((*unsafe.Pointer)(unsafe.Pointer(&p.head)), unsafe.Pointer(head), unsafe.Pointer(next)) {
			bufferPool.Put(b)
			return
		}
		runtime.Gosched()
	}
}