Lock-free data structures are presented as an alternative to mutex-based synchronization to avoid thread blocking caused by OS scheduler interruptions. Unlike mutexes, which can cause performance drops when a thread holding a lock is preempted, lock-free algorithms ensure system-wide progress.
The core of lock-free logic relies on three atomic operations: Swap, Compare And Swap (CAS), and atomic arithmetic/logic. These operations allow threads to modify memory without the risk of being interrupted between read and write phases, preventing data corruption.
The wxl library implements these concepts using hardware-level instructions such as memory barriers (std::atomic_thread_fence) to prevent instruction reordering and CPU pause (core::cpu_pause) to optimize execution during idle loops on SMT-enabled architectures.
The library includes core::atomic_trigger, a lightweight flag for coordinating events between threads. It ensures that a specific action is performed exactly once by the winning thread, replacing the traditional combination of a boolean variable and a mutex.
Another structure in the wxl library is an intrusive singly linked list where only the head is modified. This stack implementation requires no allocations during operation and allows concurrent push operations from multiple threads with a single atomic operation per element.




