Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Expose share counts in Buffer #1072

Merged
merged 1 commit into from
Jun 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/buffer/immutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,16 @@ impl<T: NativeType> Buffer<T> {
Either::Right(data) => data,
}
}

/// Get the strong count of underlying `Arc` data buffer.
pub fn shared_count_strong(&self) -> usize {
Arc::strong_count(&self.data)
}

/// Get the weak count of underlying `Arc` data buffer.
pub fn shared_count_weak(&self) -> usize {
Arc::weak_count(&self.data)
}
}

impl<T: NativeType> From<Vec<T>> for Buffer<T> {
Expand Down