refactor: Pass lifetimebound reference to SingleThreadedSchedulerClient #25040

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:2204-sched-🔭 changing 4 files +16 −13
  1. MarcoFalke commented at 7:21 am on April 30, 2022: member

    Currently a pointer is passed, which is confusing and requires run-time asserts to avoid nullptr dereference.

    All call sites can pass a reference, so do that. Also mark it LIFETIMEBOUND to avoid call sites passing a temporary. Also, unrelated cleanup in touched lines.

  2. Pass lifetimebound reference to SingleThreadedSchedulerClient fa4652ce59
  3. MarcoFalke added the label Refactoring on Apr 30, 2022
  4. pk-b2 commented at 1:33 am on May 2, 2022: none
  5. jonatack commented at 4:05 pm on May 3, 2022: member

    Code review ACK fa4652ce5995ace831b6a4d3125bfcac9563ff6f rebased to master, debug build, unit tests

    This commit:

    • passes the SingleThreadedSchedulerClient::scheduler param by reference instead of a pointer, which allows dropping a runtime non-nullptr assertion in SingleThreadedSchedulerClient::AddToProcessQueue() to avoid nullptr dereferencing (similar change in recently-merged #25016)
    • adds the clang LIFETIMEBOUND attribute to the SingleThreadedSchedulerClient and MainSignalsInstance constructors to avoid call sites passing a temporary
    • renames m_pscheduler to m_scheduler
    • adds missing header includes to scheduler.h
    • replaces a less-efficient std::bind with a lambda
    • replaces a reset(new) with preferred std::make_unique

    clang::lifetimebound is described in https://releases.llvm.org/12.0.0/tools/clang/docs/AttributeReference.html#lifetimebound:

    The lifetimebound attribute indicates that a resource owned by a function parameter or implicit object parameter is retained by the return value of the annotated function (or, for a parameter of a constructor, in the value of the constructed object).

  6. vincenzopalazzo approved
  7. MarcoFalke merged this on May 4, 2022
  8. MarcoFalke closed this on May 4, 2022

  9. MarcoFalke deleted the branch on May 4, 2022
  10. MarcoFalke referenced this in commit d17bbc3c48 on May 4, 2022
  11. sidhujag referenced this in commit 38f1a61086 on May 4, 2022
  12. sidhujag referenced this in commit cedc09f1e9 on May 4, 2022
  13. Fabcien referenced this in commit e10c411779 on Feb 15, 2023
  14. DrahtBot locked this on May 4, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-04 06:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me