#[derive(Copy, Clone, Debug, PartialOrd, Ord, PartialEq, Eq, Hash)]
pub struct GloballyCreatedLifecycle;
impl Lifecycle for GloballyCreatedLifecycle
{
#[inline(always)]
fn free(ring: *mut rte_ring)
{
unsafe { ::dpdk_sys::rte_ring_free(ring) }
}
}
impl GloballyCreatedLifecycle
{
pub fn new
(
name: &str, maximumCountPowerOfTwoUpto32Exclusive: u8,
numaSocketId: Option<NumaSocketId>,
ringQueueProducerConsumerVariant: RingQueueProducerConsumerVariant
) -> Option<RingQueue<InefficientProducer, InefficientConsumer, GloballyCreatedLifecycle>>
{
#[cfg(debug_assertions)] Self::guardMaximumNameLength(name);
let cName = CString::new(name).expect("GloballyCreatedLifecycle.new() name contained an interior ASCII NUL and couldn't be converted to a CString");
let maximumCount: c_uint = 2 << maximumCountPowerOfTwoUpto32Exclusive as c_uint;
let result = unsafe { ::dpdk_sys::rte_ring_create(cName.as_ptr(), maximumCount, numaSocketId.as_c_int(), ringQueueProducerConsumerVariant as c_uint) };
if unlikely(result.is_null())
{
match unsafe { rust_rte_errno() }
{
E_RTE::NO_CONFIG => panic!("rte_ring_create() could not get pointer to rte_config structure"),
E_RTE::SECONDARY => panic!("rte_ring_create() was called from a secondary process instance"),
E::EINVAL => panic!("rte_ring_create(): count provided is not a power of 2; we provided maximumCount of '{}'", maximumCount),
E::ENOSPC => panic!("rte_ring_create(): the maximum number of memzones has already been allocated"),
E::EEXIST => panic!("rte_ring_create(): a memzone with the same name already exists"),
E::ENOMEM => panic!("rte_ring_create(): no appropriate memory area found in which to create memzone"),
unexpected @ _ => panic!("Unexpected error code '{}' from rte_ring_create()", unexpected),
}
}
else
{
Some(RingQueue::new(result))
}
}
}