Refactor the spark queue implementation into a generic work-stealing deque