fully functional and uses atomic_flag