added function to block on the ring buffer until it es empty
made pointers volatile (fixes lock when in O3)
design cosmetics in the processing loop