implementation with spinning queue