Skip to content

Allow the user to pick read-only or read-write locking#32

Merged
HaoZeke merged 2 commits into
mainfrom
pick-read-write
May 7, 2026
Merged

Allow the user to pick read-only or read-write locking#32
HaoZeke merged 2 commits into
mainfrom
pick-read-write

Conversation

@Luthaf

@Luthaf Luthaf commented May 6, 2026

Copy link
Copy Markdown
Member

The goal is to enable Rust code to create and modify arrays, and then only hand out read-only references through as_dlpack()

This can be controlled by passing either ReadOnly<...> or ReadWrite<...> to try_into

Comment thread src/sync.rs

let mut data = std::ptr::null_mut();
ctx.with_lock_mut(|lock| {
// Cast mut is fine, we set the read-only flag in the DLPack tensor

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this include // SAFETY: Promises to honor DLPack flag

@HaoZeke HaoZeke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just a very minor nit. Later we might want to have an error return instead of expect() on the lock stuff, but not now.

@HaoZeke
HaoZeke merged commit 061f11f into main May 7, 2026
6 checks passed
@HaoZeke
HaoZeke deleted the pick-read-write branch May 7, 2026 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants