impl spinlock and memory barrier