Skip to content
  • gab's avatar
    TaskScheduler: Avoid Sequence refcount bump in GetWork() · eaec122b
    gab authored
    vmpstr@ discovered an implicit copy constructor resulting
    in a refcount bump in https://codereview.chromium.org/1895903003/
    and made it explicit in https://codereview.chromium.org/1901223003/
    this CL removes the need for it via a couple changes:
    
    1) Make SequenceAndSortKey move-only
     - Allows it to be in std::priority_queue without std::unique_ptr's
      - Less pointer chasing == yay?!
     - Removing need for custom SequenceAndSortKeyComparator.
    2) Add a take_sequence() method to it:
     - Allows to take its Sequence without refbump on Pop()
    3) Make it a private implementation detail and make Transaction's API:
     - Push(sequence,sort_key), PeekSortKey(), PopSequence()
    4) Do fdoray's TODO on adding IsEmpty() to Transaction's API:
     - Removes need for null SequenceAndSortKey (required change to allow for PeekSortKey).
    5) Make SequenceSortKey copyable.
     - Required for SequenceAndSortKey's move constructor
     - Means it turns into a class with operator== for tests instead of custom
       test member verifiers.
    
    Might have been able to split these up but they all line up fairly nicely
    and don't amount to a crazy amount of code so here it is :-).
    
    BUG=553459
    
    Review-Url: https://codereview.chromium.org/1903133003
    Cr-Commit-Position: refs/heads/master@{#390451}
    eaec122b