mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-26 00:00:20 +02:00
Add TSAN support (#541)
This commit is contained in:
+5
-2
@@ -13,7 +13,7 @@ use alloc::{
|
|||||||
use crate::buf::IntoIter;
|
use crate::buf::IntoIter;
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
use crate::loom::sync::atomic::AtomicMut;
|
use crate::loom::sync::atomic::AtomicMut;
|
||||||
use crate::loom::sync::atomic::{self, AtomicPtr, AtomicUsize, Ordering};
|
use crate::loom::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
|
||||||
use crate::Buf;
|
use crate::Buf;
|
||||||
|
|
||||||
/// A cheaply cloneable and sliceable chunk of contiguous memory.
|
/// A cheaply cloneable and sliceable chunk of contiguous memory.
|
||||||
@@ -1095,7 +1095,10 @@ unsafe fn release_shared(ptr: *mut Shared) {
|
|||||||
// > "acquire" operation before deleting the object.
|
// > "acquire" operation before deleting the object.
|
||||||
//
|
//
|
||||||
// [1]: (www.boost.org/doc/libs/1_55_0/doc/html/atomic/usage_examples.html)
|
// [1]: (www.boost.org/doc/libs/1_55_0/doc/html/atomic/usage_examples.html)
|
||||||
atomic::fence(Ordering::Acquire);
|
//
|
||||||
|
// Thread sanitizer does not support atomic fences. Use an atomic load
|
||||||
|
// instead.
|
||||||
|
(*ptr).ref_cnt.load(Ordering::Acquire);
|
||||||
|
|
||||||
// Drop the data
|
// Drop the data
|
||||||
Box::from_raw(ptr);
|
Box::from_raw(ptr);
|
||||||
|
|||||||
+5
-2
@@ -16,7 +16,7 @@ use crate::buf::{IntoIter, UninitSlice};
|
|||||||
use crate::bytes::Vtable;
|
use crate::bytes::Vtable;
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
use crate::loom::sync::atomic::AtomicMut;
|
use crate::loom::sync::atomic::AtomicMut;
|
||||||
use crate::loom::sync::atomic::{self, AtomicPtr, AtomicUsize, Ordering};
|
use crate::loom::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
|
||||||
use crate::{Buf, BufMut, Bytes};
|
use crate::{Buf, BufMut, Bytes};
|
||||||
|
|
||||||
/// A unique reference to a contiguous slice of memory.
|
/// A unique reference to a contiguous slice of memory.
|
||||||
@@ -1288,7 +1288,10 @@ unsafe fn release_shared(ptr: *mut Shared) {
|
|||||||
// > "acquire" operation before deleting the object.
|
// > "acquire" operation before deleting the object.
|
||||||
//
|
//
|
||||||
// [1]: (www.boost.org/doc/libs/1_55_0/doc/html/atomic/usage_examples.html)
|
// [1]: (www.boost.org/doc/libs/1_55_0/doc/html/atomic/usage_examples.html)
|
||||||
atomic::fence(Ordering::Acquire);
|
//
|
||||||
|
// Thread sanitizer does not support atomic fences. Use an atomic load
|
||||||
|
// instead.
|
||||||
|
(*ptr).ref_count.load(Ordering::Acquire);
|
||||||
|
|
||||||
// Drop the data
|
// Drop the data
|
||||||
Box::from_raw(ptr);
|
Box::from_raw(ptr);
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
#[cfg(not(all(test, loom)))]
|
#[cfg(not(all(test, loom)))]
|
||||||
pub(crate) mod sync {
|
pub(crate) mod sync {
|
||||||
pub(crate) mod atomic {
|
pub(crate) mod atomic {
|
||||||
pub(crate) use core::sync::atomic::{fence, AtomicPtr, AtomicUsize, Ordering};
|
pub(crate) use core::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
|
||||||
|
|
||||||
pub(crate) trait AtomicMut<T> {
|
pub(crate) trait AtomicMut<T> {
|
||||||
fn with_mut<F, R>(&mut self, f: F) -> R
|
fn with_mut<F, R>(&mut self, f: F) -> R
|
||||||
@@ -23,7 +23,7 @@ pub(crate) mod sync {
|
|||||||
#[cfg(all(test, loom))]
|
#[cfg(all(test, loom))]
|
||||||
pub(crate) mod sync {
|
pub(crate) mod sync {
|
||||||
pub(crate) mod atomic {
|
pub(crate) mod atomic {
|
||||||
pub(crate) use loom::sync::atomic::{fence, AtomicPtr, AtomicUsize, Ordering};
|
pub(crate) use loom::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
|
||||||
|
|
||||||
pub(crate) trait AtomicMut<T> {}
|
pub(crate) trait AtomicMut<T> {}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user