he Nodes are removed from theWaitingQueue by concurrent working threads. If
theNeedToUpdate field of the Node is "true" then this Node was already visited
by the tree walk (described here). No significant operation is performed in
such case. If theNeedToUpdate is "false" then such Node does not have any
Sources (Parents) in dependency tree that were removed from theWaitingQueue.
In such case, the procedure walks through dependency tree (Listeners,
depth-first) of the Node. It goes only deep enough to set theNeedToUpdate to
"true". When it encounters theNeedToUpdate that is already "true" then it
reverses the direction of walk, it does not go deeper. On every visit the
procedure increments theNumberOfSourcesOutOfDate by 1 and removes the visited
Node from theUpdateQueue. When such process is finished, theWaitingQueue is
empty, theUpdateQueue contains the out-of-date Nodes that do not have
out-of-date Parents (Sources) and every Node in the tree knows exactly how
many of its immediate parents are out-of-date.
At that point the procedure starts to remove the Nodes from theUpdateQueue by
concurrent working threads. Every such Node updates (operation on theProxy
field), sends failure or success notification (operation on theOrigin field)
and decrements theNumberOfSourcesOutOfDate for all Children (Listeners). Those
Listeners whose theNumberOfSourcesOutOfDate becomes zero are placed into
theUpdateQueue. When this process is finished, all the out-of-date Nodes were
brought up-to-date in optimal order.
|