bitflags!
{
pub struct HardwareMemoryTransactionResult: u32
{
#[doc(hidden)]
const _XABORT_EXPLICIT = _XABORT_EXPLICIT;
#[doc(hidden)]
const _XABORT_RETRY = _XABORT_RETRY;
#[doc(hidden)]
const _XABORT_CONFLICT = _XABORT_CONFLICT;
#[doc(hidden)]
const _XABORT_CAPACITY = _XABORT_CAPACITY;
#[doc(hidden)]
const _XABORT_DEBUG = _XABORT_DEBUG;
#[doc(hidden)]
const _XABORT_NESTED = _XABORT_NESTED;
}
}
impl HardwareMemoryTransactionResult
{
pub const TransactionFailedDueToBusyLock: u8 = 0xFF;
#[inline(always)]
fn new(status: u32) -> Self
{
debug_assert_ne!(status, _XBEGIN_STARTED, "status should not be _XBEGIN_STARTED");
Self
{
bits: status,
}
}
#[inline(always)]
pub fn transaction_was_explicitly_aborted_by_callback(self) -> Option<u8>
{
if self.contains(Self::_XABORT_EXPLICIT)
{
Some(_XABORT_CODE(self.bits))
}
else
{
None
}
}
#[inline(always)]
pub fn transaction_retry_is_possible(self) -> bool
{
self.contains(Self::_XABORT_RETRY)
}
#[inline(always)]
pub fn transaction_was_aborted_due_to_conflict_with_another_thread(self) -> bool
{
self.contains(Self::_XABORT_CONFLICT)
}
#[inline(always)]
pub fn transaction_was_aborted_due_to_using_too_much_memory(self) -> bool
{
self.contains(Self::_XABORT_CAPACITY)
}
#[inline(always)]
pub fn transaction_was_aborted_due_to_a_debug_trap(self) -> bool
{
self.contains(Self::_XABORT_DEBUG)
}
#[inline(always)]
pub fn transaction_was_aborted_due_to_issuing_a_nested_transaction(self) -> bool
{
self.contains(Self::_XABORT_NESTED)
}
}