aboutsummaryrefslogtreecommitdiff
path: root/rust/kernel/sync.rs
AgeCommit message (Collapse)AuthorFilesLines
2023-01-16rust: sync: introduce `UniqueArc`Wedson Almeida Filho1-1/+1
Since `Arc<T>` does not allow mutating `T` directly (i.e., without inner mutability), it is currently not possible to do some initialisation of `T` post construction but before being shared. `UniqueArc<T>` addresses this problem essentially being an `Arc<T>` that has a refcount of 1 and is therefore writable. Once initialisation is completed, it can be transitioned (without failure paths) into an `Arc<T>`. Suggested-by: Gary Guo <[email protected]> Signed-off-by: Wedson Almeida Filho <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Gary Guo <[email protected]> Reviewed-by: Vincenzo Palazzo <[email protected]> Acked-by: Boqun Feng <[email protected]> Signed-off-by: Miguel Ojeda <[email protected]>
2023-01-16rust: sync: introduce `ArcBorrow`Wedson Almeida Filho1-1/+1
This allows us to create references to a ref-counted allocation without double-indirection and that still allow us to increment the refcount to a new `Arc<T>`. Signed-off-by: Wedson Almeida Filho <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Acked-by: Boqun Feng <[email protected]> Reviewed-by: Gary Guo <[email protected]> Reviewed-by: Vincenzo Palazzo <[email protected]> Signed-off-by: Miguel Ojeda <[email protected]>
2023-01-16rust: sync: add `Arc` for ref-counted allocationsWedson Almeida Filho1-0/+10
This is a basic implementation of `Arc` backed by C's `refcount_t`. It allows Rust code to idiomatically allocate memory that is ref-counted. Cc: Will Deacon <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Boqun Feng <[email protected]> Cc: Mark Rutland <[email protected]> Signed-off-by: Wedson Almeida Filho <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Gary Guo <[email protected]> Reviewed-by: Vincenzo Palazzo <[email protected]> Acked-by: Boqun Feng <[email protected]> Signed-off-by: Miguel Ojeda <[email protected]>