func (r *Ring) Count() uint {
	return uint(C.rte_ring_count((*C.struct_rte_ring)(r)))
}
Count returns the number of entries in a ring.
package ring
import "C"
import (
	"runtime"
	"unsafe"
	"github.com/yerden/go-dpdk/common"
)
type Ring C.struct_rte_ring
type ringConf struct {
	cname  *C.char
	socket C.int
	flags  C.uint
}
type Option struct {
	f func(*ringConf)
}
const (
	SingleConsumer uint = C.RING_F_SC_DEQ
	SingleProducer = C.RING_F_SP_ENQ
	ExactSize = C.RING_F_EXACT_SZ
)
var (
	OptSC = OptFlag(SingleConsumer)
	OptSP = OptFlag(SingleProducer)
	OptES = OptFlag(ExactSize)
)
func err(n ...interface{}) error {
	if len(n) == 0 {
		return common.RteErrno()
	}
	return common.IntToErr(n[0])
}
func OptSocket(socket uint) Option {
	return Option{func(rc *ringConf) {
		rc.socket = C.int(socket)
	}}
}
func OptFlag(flag uint) Option {
	return Option{func(rc *ringConf) {
		rc.flags |= C.uint(flag)
	}}
}
func makeOpts(name string, opts []Option) *ringConf {
	rc := &ringConf{socket: C.SOCKET_ID_ANY}
	rc.cname = C.CString(name)
	for i := range opts {
		opts[i].f(rc)
	}
	runtime.SetFinalizer(rc, func(rc *ringConf) {
		C.free(unsafe.Pointer(rc.cname))
	})
	return rc
}
func Create(name string, count uint, opts ...Option) (*Ring, error) {
	rc := makeOpts(name, opts)
	r := (*Ring)(C.rte_ring_create(rc.cname, C.uint(count), rc.socket, rc.flags))
	if r == nil {
		return nil, err()
	}
	return r, nil
}
func (r *Ring) Init(name string, count uint, opts ...Option) error {
	rc := makeOpts(name, opts)
	return err(C.rte_ring_init((*C.struct_rte_ring)(r), rc.cname,
		C.uint(count), rc.flags))
}
func New(name string, count uint, opts ...Option) (*Ring, error) {
	size, err := GetMemSize(count)
	if err != nil {
		return nil, err
	}
	p := make([]byte, size)
	r := (*Ring)(unsafe.Pointer(&p[0]))
	return r, r.Init(name, count, opts...)
}
func GetMemSize(count uint) (int, error) {
	sz := C.rte_ring_get_memsize(C.uint(count))
	return common.IntOrErr(int(sz))
}
func (r *Ring) Free() {
	C.rte_ring_free((*C.struct_rte_ring)(r))
}