Spin-wait for lock while updating the graph.

Locks will be for minimal duration.