* Try to take the recursive lock. * * @param tlr * A pointer to the recursive ticketlock. * @return * 1 if the lock is successfully taken; 0 otherwise. */
| 196 | * 1 if the lock is successfully taken; 0 otherwise. |
| 197 | */ |
| 198 | static inline int |
| 199 | rte_ticketlock_recursive_trylock(rte_ticketlock_recursive_t *tlr) |
| 200 | { |
| 201 | int id = rte_gettid(); |
| 202 | |
| 203 | if (rte_atomic_load_explicit(&tlr->user, rte_memory_order_relaxed) != id) { |
| 204 | if (rte_ticketlock_trylock(&tlr->tl) == 0) |
| 205 | return 0; |
| 206 | rte_atomic_store_explicit(&tlr->user, id, rte_memory_order_relaxed); |
| 207 | } |
| 208 | tlr->count++; |
| 209 | return 1; |
| 210 | } |
| 211 | |
| 212 | #ifdef __cplusplus |
| 213 | } |