Fix a GN race condition.

The loader maintains a reference count on the "pending work". But the
Setup object was starting the load before incrementing this reference count.
It the loader happened to load anything on the background thread before the
main thread could increment the reference count, GN would think there is no
work left and exit early.

There is another possible race condition between defining items and doing
work on the thread pool can cause the build to be marked complete before
everything is actually done. The race condition is described in more detail
in the added comment in setup.cc.

BUG=674213

Review-Url: https://codereview.chromium.org/2617253002
Cr-Original-Commit-Position: refs/heads/master@{#442416}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 717182cd794aae4577fbae651a88e3ba6d973dc8
1 file changed
tree: 30a9d23b3b453946f230a82874cbba6af3c539bb
  1. tools/