Represents a distribution context (e.g., in-tower or cross-tower).
Distribution contexts are used to constrain what actions are allowed at every point in the code, and enforce those
constraints at compile time, using implicits. More specifically, the current distribution context is always
available implicitly and can be checked (e.g., some method require an implicit cross-tower context and will not be
able to compile if there current context is an in-tower context).
For example, for the following execution steps:
Start in the default (single-tower) tower context (i.e., implicit in-tower context is available).
2. Switch to a cross-tower context, when entering a distribution strategy scope (this will make available a
cross-tower context implicit, for the all code within that scope).
3. Switch to a (non-default) tower context inside forEachTower(fn, ...) (i.e., the code in fn will have an
in-tower implicit context available).
4. If fn calls currentTowerContext->mergeCall(mergeFn, ...), then inside mergeFn, a cross-tower context
will again be implicitly available.
Note that you can also go directly from step 1 to 4 to switch to a cross-tower context for the default distribution
strategy. You may also switch from the cross-tower context of 4 to an in-tower context by calling
forEachTower(), jumping back to step 3.
Most distribution API methods may only be executed in cross-tower contexts.
Represents a distribution context (e.g., in-tower or cross-tower).
Distribution contexts are used to constrain what actions are allowed at every point in the code, and enforce those constraints at compile time, using implicits. More specifically, the current distribution context is always available implicitly and can be checked (e.g., some method require an implicit cross-tower context and will not be able to compile if there current context is an in-tower context).
For example, for the following execution steps:
forEachTower(fn, ...)
(i.e., the code infn
will have an in-tower implicit context available). 4. Iffn
callscurrentTowerContext->mergeCall(mergeFn, ...)
, then insidemergeFn
, a cross-tower context will again be implicitly available.Note that you can also go directly from step 1 to 4 to switch to a cross-tower context for the default distribution strategy. You may also switch from the cross-tower context of 4 to an in-tower context by calling
forEachTower()
, jumping back to step 3.Most distribution API methods may only be executed in cross-tower contexts.