Add a convenience object for expressing once-like / per-runtime patterns (#55793)
This adds 3 new types, to conveniently express 3 common concurrent code
patterns:
- `PerProcess`: an action that must be taken once per process
- `PerThread`: an action that must be taken once per thread id
- `PerTask`: an action that must be take once per task object
The PerProcess object should replace `__init__` or similar hand rolled
implementations of this.
The PerThread object should replace code that used to use `nthreads()`
to implement a much less correct version of this (though this is not
recommended in most new code, some foreign libraries may need this to
interact well with C).
The PerTask object is simply a thin wrapper over `task_local_storage()`.