Skip to content

Instantly share code, notes, and snippets.

@erickt
Created July 30, 2018 17:42
Show Gist options
  • Save erickt/ec1598587b23ff3a3d7f063092071fac to your computer and use it in GitHub Desktop.
Save erickt/ec1598587b23ff3a3d7f063092071fac to your computer and use it in GitHub Desktop.
async fn update_root<V, U>(&self, ...) -> ... {
Box::new(async {
// 1. first we grab the lock
let tuf = self.tuf.lock().unwrap();
// 2. yield to the scheduler
let signed = await!(
repo.fetch_metadata(...)
);
// 4. if we're a single threaded executor, we'll never resume here
// because we're blocked waiting on the lock. however if we have
// multiple executor threads, we can eventually steal this task
// to handle when `fetch_metadata` finishes, unless all the
// threads have gotten stuck waiting for locks in the current
// thread.
...
})
}
async fn update_timestamp<V, U>(&self, ...) -> ... {
Box::new(async {
// 3. we try to grab the lock and hang
let tuf = self.tuf.lock().unwrap();
...
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment