AngouriMath
AngouriMath.Convenience
Classes within the AngouriMath.Convenience namespace
ISettingState
Summary
A setting, without its value's type — enough to ask what it currently reads as.Setting`1
Summary
This class for configuring some internal mechanisms from outside
Type parameter "T"
Those configurations can be of different types
Remarks
A setting is one object for the whole process, and what it holds is per *flow*, not
per thread: the stack of values lives in an AsyncLocal`1. A scope
opened before anawait is therefore still in force after it, and a
scope opened inside a task is invisible to that task's siblings and to whatever
started it. Backing the field with[ThreadStatic] gave neither: a continuation
resumed on a pool thread saw the defaults, and a thread returned to the pool carried
whatever scope was left on it into the next caller.
The frames are immutable, which is what makes the reference safe to share. An
AsyncLocal`1 copies on assignment to Value and on nothing else, so if a frame could be mutated in place, two flows holding the
same chain would write over each other. Pushing and popping therefore build a new
chain and assign it, rather than editing one.
SettingsState
Summary
What every setting reads as, taken together, so that something holding a result computed
under the settings of a moment can tell whether those settings still hold.
Remarks
A state and not a change count. Counting changes looks equivalent and is not: a
scope opened and closed leaves every setting exactly as it found it while moving a
counter twice, and the library opens such scopes constantly — a single
Simplify of one unevaluated integral opened 3520 of them, all four from
numeric downcasting inNumber/Operators.cs . A counter therefore reports
"everything has changed" continuously and is useless to a cache. Measured, not assumed:
the counter was built first and threw away the whole benefit.
The state of one setting is the reference to the frame on top of its stack, which
is exact rather than a hash — releasing a scope restores the very frame object that was
there before it, since the chain below a pushed frame is never rebuilt. So comparing
snapshots is a handful of reference comparisons with no chance of collision, and a
balanced open-and-close compares equal, which is the whole point.
Angouri © 2019-2023 · Project's repo · Site's repo · Octicons · Transparency · 4405 pages online