protect operations with spinlock