func (mp *Mempool) PopulateAnon() (int, error) {
	rc := C.rte_mempool_populate_anon((*C.struct_rte_mempool)(mp))
	return common.IntOrErr(rc)
}
PopulateAnon adds memory from anonymous mapping for objects in the pool at
init. This function mmap an anonymous memory zone that is locked in memory
to store the objects of the mempool.
package mempool
import "C"
import (
	"reflect"
	"unsafe"
	"github.com/yerden/go-dpdk/common"
)
type Factory interface {
	NewMempool(string, []Option) (*Mempool, error)
}
type FactoryFunc func(string, []Option) (*Mempool, error)
func (fn FactoryFunc) NewMempool(name string, opts []Option) (*Mempool, error) {
	return fn(name, opts)
}
type Mempool C.struct_rte_mempool
type mpConf struct {
	cacheSize    C.uint
	privDataSize C.uint
	socket       C.int
	flags        C.uint
	opsName *string
}
func err(n ...interface{}) error {
	if len(n) == 0 {
		return common.RteErrno()
	}
	return common.IntToErr(n[0])
}
type Option struct {
	f func(*mpConf)
}
func OptOpsName(name string) Option {
	return Option{func(conf *mpConf) {
		conf.opsName = &name
	}}
}
func OptCacheSize(size uint32) Option {
	return Option{func(conf *mpConf) {
		conf.cacheSize = C.uint(size)
	}}
}
func OptPrivateDataSize(size uint32) Option {
	return Option{func(conf *mpConf) {
		conf.privDataSize = C.uint(size)
	}}
}
func OptSocket(socket int) Option {
	return Option{func(conf *mpConf) {
		conf.socket = C.int(socket)
	}}
}
func OptFlag(flag uint) Option {
	return Option{func(conf *mpConf) {
		conf.flags |= C.uint(flag)
	}}
}
const (
	NoSpread uint = C.MEMPOOL_F_NO_SPREAD
	NoCacheAlign = C.MEMPOOL_F_NO_CACHE_ALIGN
	SPPut = C.MEMPOOL_F_SP_PUT
	SCGet = C.MEMPOOL_F_SC_GET
)
var (
	OptNoSpread     = OptFlag(NoSpread)
	OptNoCacheAlign = OptFlag(NoCacheAlign)
	OptSPPut        = OptFlag(SPPut)
	OptSCGet        = OptFlag(SCGet)
)
func CreateEmpty(name string, n, eltsize uint32, opts ...Option) (*Mempool, error) {
	conf := &mpConf{socket: C.SOCKET_ID_ANY}
	for i := range opts {
		opts[i].f(conf)
	}
	cname := C.CString(name)
	mp := (*Mempool)(C.rte_mempool_create_empty(cname, C.uint(n), C.uint(eltsize),
		conf.cacheSize, conf.privDataSize, conf.socket, conf.flags))
	C.free(unsafe.Pointer(cname))
	if mp == nil {
		return nil, err()
	}
	return (*Mempool)(mp), nil
}
func (mp *Mempool) SetOpsRing() error {
	var ops string
	if mp.flags&C.MEMPOOL_F_SP_PUT != 0 {
		ops = "ring_sp"
	} else {
		ops = "ring_mp"
	}
	if mp.flags&C.MEMPOOL_F_SC_GET != 0 {
		ops += "_sc"
	} else {
		ops += "_mc"
	}
	return mp.SetOpsByName(ops, nil)
}
func (mp *Mempool) SetOpsByName(name string, poolConfig unsafe.Pointer) error {
	cname := C.CString(name)
	defer C.free(unsafe.Pointer(cname))
	cmp := (*C.struct_rte_mempool)(mp)
	return err(C.rte_mempool_set_ops_byname(cmp, cname, poolConfig))
}
func (mp *Mempool) PopulateDefault() (int, error) {
	rc := C.rte_mempool_populate_default((*C.struct_rte_mempool)(mp))
	return common.IntOrErr(rc)
}