Lock-free ring buffer for inter-thread communication