[][src]Trait ra_ap_base_db::CheckCanceled

pub trait CheckCanceled {
    fn check_canceled(&self);

    fn catch_canceled<F, T>(&self, f: F) -> Result<T, Canceled>
    where
        Self: Sized + RefUnwindSafe,
        F: FnOnce(&Self) -> T + UnwindSafe
, { ... } }

Required methods

fn check_canceled(&self)

Aborts current query if there are pending changes.

rust-analyzer needs to be able to answer semantic questions about the code while the code is being modified. A common problem is that a long-running query is being calculated when a new change arrives.

We can't just apply the change immediately: this will cause the pending query to see inconsistent state (it will observe an absence of repeatable read). So what we do is we cancel all pending queries before applying the change.

We implement cancellation by panicking with a special value and catching it on the API boundary. Salsa explicitly supports this use-case.

Loading content...

Provided methods

fn catch_canceled<F, T>(&self, f: F) -> Result<T, Canceled> where
    Self: Sized + RefUnwindSafe,
    F: FnOnce(&Self) -> T + UnwindSafe

Loading content...

Implementors

impl<T: Database> CheckCanceled for T[src]

Loading content...