Skip to content

Instantly share code, notes, and snippets.

View ocecaco's full-sized avatar

Daniël Louwrink ocecaco

View GitHub Profile
@ocecaco
ocecaco / stackedborrows-lockinference.md
Created July 4, 2021 13:27
Stacked Borrows as lock inference

Stacked Borrows as lock inference

I will argue that Stacked Borrows can be viewed as an approximation of a special kind of re-entrant (reader-writer) lock, where the calls to lock and unlock are hidden, and Stacked Borrows attempts to infer where they happen. The locking intuition seems like it might be useful for several reasons:

  1. It directly expresses "aliasing XOR mutability" by the fact that at most one user can hold the write lock at any moment, and any number of users can hold the read lock.