mirror of
https://github.com/salsa-rs/salsa.git
synced 2024-11-24 04:09:36 +00:00
Apply suggestions from code review
Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
This commit is contained in:
parent
2ea6759b0f
commit
8e2a784b8e
1 changed files with 4 additions and 2 deletions
|
@ -4,13 +4,15 @@ Panicking when a cycle occurs is ok for situations where you believe a cycle is
|
|||
|
||||
To use cycle recovery, you annotate potential participants in the cycle with the `recovery_fn` argument to `#[salsa::tracked]`, e.g. `#[salsa::tracked(recovery_fn=my_recovery_fn)]`. When a cycle occurs, if any participant P has recovery information, then no panic occurs. Instead, the execution of P is aborted and P will execute the recovery function to generate its result. Participants in the cycle that do not have recovery information continue executing as normal, using this recovery result.
|
||||
|
||||
The recovery function has a similar signature to a query function. It is given a reference to your database along with a `salsa::Cycle` describing the cycle that occurred and the input ingredient to the query that caused the cycle; it returns the result of the query. Example:
|
||||
The recovery function has a similar signature to a query function. It is given a reference to your database along with a `salsa::Cycle` describing the cycle that occurred and the arguments to the tracked function that caused the cycle; it returns the result of the query. Example:
|
||||
|
||||
```rust
|
||||
fn my_recover_fn(
|
||||
db: &dyn MyDatabase,
|
||||
cycle: &salsa::Cycle,
|
||||
input: MyIngredient,
|
||||
arg1: T1,
|
||||
...
|
||||
argN: TN,
|
||||
) -> MyResultValue
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in a new issue