Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require Send+Sync bounds for Allocation trait #1945

Merged
merged 1 commit into from Jun 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions arrow/src/alloc/mod.rs
Expand Up @@ -127,9 +127,9 @@ pub unsafe fn reallocate<T: NativeType>(

/// The owner of an allocation.
/// The trait implementation is responsible for dropping the allocations once no more references exist.
pub trait Allocation: RefUnwindSafe {}
pub trait Allocation: RefUnwindSafe + Send + Sync {}

impl<T: RefUnwindSafe> Allocation for T {}
impl<T: RefUnwindSafe + Send + Sync> Allocation for T {}

/// Mode of deallocating memory regions
pub(crate) enum Deallocation {
Expand Down
5 changes: 0 additions & 5 deletions arrow/src/buffer/immutable.rs
Expand Up @@ -257,11 +257,6 @@ impl std::ops::Deref for Buffer {
}
}

unsafe impl Sync for Buffer {}
// false positive, see https://github.com/apache/arrow-rs/pull/1169
#[allow(clippy::non_send_fields_in_send_ty)]
unsafe impl Send for Buffer {}

impl From<MutableBuffer> for Buffer {
#[inline]
fn from(buffer: MutableBuffer) -> Self {
Expand Down
5 changes: 5 additions & 0 deletions arrow/src/bytes.rs
Expand Up @@ -101,6 +101,11 @@ impl Bytes {
}
}

// Deallocation is Send + Sync, repeating the bound here makes that refactoring safe
// The only field that is not automatically Send+Sync then is the NonNull ptr
unsafe impl Send for Bytes where Deallocation: Send {}
unsafe impl Sync for Bytes where Deallocation: Sync {}

impl Drop for Bytes {
#[inline]
fn drop(&mut self) {
Expand Down
3 changes: 3 additions & 0 deletions arrow/src/ffi.rs
Expand Up @@ -409,6 +409,9 @@ impl Drop for FFI_ArrowArray {
}
}

unsafe impl Send for FFI_ArrowArray {}
unsafe impl Sync for FFI_ArrowArray {}

// callback used to drop [FFI_ArrowArray] when it is exported
unsafe extern "C" fn release_array(array: *mut FFI_ArrowArray) {
if array.is_null() {
Expand Down