[history] Fix incremental loading: reduce number of spawned jobs
Incremental history loading in some cases scheduled way too many
background threads to load the next batch of commits. Change the
logic to account for the history already being fully loaded, and
to avoid scheduling unnecessary jobs.
Make the logic thread-safe. Copy the relevant data (number of already
loaded commits and whether the history is fully loaded) from the commit
list into local fields so that the job is still the only entity that
accesses the commit list.
Bug: 577913
Change-Id: I4fe55f5c55a5a4b729d764e0074b692cf61ad002
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>