src/dpdk/lib/librte_eal/include/generic/rte_ticketlock.h
static inline int
rte_ticketlock_trylock(rte_ticketlock_t *tl)
{
	rte_ticketlock_t old, new;
	old.tickets = __atomic_load_n(&tl->tickets, __ATOMIC_RELAXED);
	new.tickets = old.tickets;
	new.s.next++;
	if (old.s.next == old.s.current) {
		if (__atomic_compare_exchange_n(&tl->tickets, &old.tickets,
		    new.tickets, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
			return 1;
	}

	return 0;
}
/**
 * Try to take the lock.
 *
 * @param tl
 *   A pointer to the ticketlock.
 * @return
 *   1 if the lock is successfully taken; 0 otherwise.
 */
Try to take the lock.
@param tl
A pointer to the ticketlock.
@return
1 if the lock is successfully taken; 0 otherwise.
Try to take the lock . @param tl A pointer to the ticketlock . @return 1 if the lock is successfully taken ; 0 otherwise .
static inline int
rte_ticketlock_trylock(rte_ticketlock_t *tl)
{
	rte_ticketlock_t old, new;
	old.tickets = __atomic_load_n(&tl->tickets, __ATOMIC_RELAXED);
	new.tickets = old.tickets;
	new.s.next++;
	if (old.s.next == old.s.current) {
		if (__atomic_compare_exchange_n(&tl->tickets, &old.tickets,
		    new.tickets, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
			return 1;
	}
	return 0;
}
static inline int rte_ticketlock_trylock ( rte_ticketlock_t * tl ) { rte_ticketlock_t old , new ; old . tickets = __atomic_load_n ( & tl -> tickets , __ATOMIC_RELAXED ) ; new . tickets = old . tickets ; new . s . next ++ ; if ( old . s . next == old . s . current ) { if ( __atomic_compare_exchange_n ( & tl -> tickets , & old . tickets , new . tickets , 0 , __ATOMIC_ACQUIRE , __ATOMIC_RELAXED ) ) return 1 ; } return 0 ; }
Try to take the lock.
Try to take the lock .