mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 22:31:14 +00:00
Make it possible to compile sharedvector and sharedstring with atomic-polyfill
This commit is contained in:
parent
b52f41b51f
commit
e8302452b5
2 changed files with 5 additions and 3 deletions
|
@ -51,6 +51,7 @@ unicode-segmentation = "1.8.0"
|
||||||
# Note: the rgb version is extracted in ci.yaml for rustdoc builds
|
# Note: the rgb version is extracted in ci.yaml for rustdoc builds
|
||||||
rgb = "0.8.27"
|
rgb = "0.8.27"
|
||||||
pin-project = "1"
|
pin-project = "1"
|
||||||
|
atomic-polyfill = { version = "0.1.5" }
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
instant = { version = "0.1", features = [ "wasm-bindgen", "now" ] }
|
instant = { version = "0.1", features = [ "wasm-bindgen", "now" ] }
|
||||||
|
|
|
@ -15,7 +15,8 @@ use core::iter::FromIterator;
|
||||||
use core::mem::MaybeUninit;
|
use core::mem::MaybeUninit;
|
||||||
use core::ops::Deref;
|
use core::ops::Deref;
|
||||||
use core::ptr::NonNull;
|
use core::ptr::NonNull;
|
||||||
use core::sync::atomic;
|
|
||||||
|
use atomic_polyfill as atomic;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
struct SharedVectorHeader {
|
struct SharedVectorHeader {
|
||||||
|
@ -38,7 +39,7 @@ fn compute_inner_layout<T>(capacity: usize) -> core::alloc::Layout {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn drop_inner<T>(mut inner: NonNull<SharedVectorInner<T>>) {
|
unsafe fn drop_inner<T>(mut inner: NonNull<SharedVectorInner<T>>) {
|
||||||
debug_assert_eq!(inner.as_ref().header.refcount.load(core::sync::atomic::Ordering::Relaxed), 0);
|
debug_assert_eq!(inner.as_ref().header.refcount.load(atomic::Ordering::Relaxed), 0);
|
||||||
let data_ptr = inner.as_mut().data.as_mut_ptr();
|
let data_ptr = inner.as_mut().data.as_mut_ptr();
|
||||||
for x in 0..inner.as_ref().header.size {
|
for x in 0..inner.as_ref().header.size {
|
||||||
core::ptr::drop_in_place(data_ptr.add(x));
|
core::ptr::drop_in_place(data_ptr.add(x));
|
||||||
|
@ -377,7 +378,7 @@ impl<T: Clone> Extend<T> for SharedVector<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
static SHARED_NULL: SharedVectorHeader =
|
static SHARED_NULL: SharedVectorHeader =
|
||||||
SharedVectorHeader { refcount: core::sync::atomic::AtomicIsize::new(-1), size: 0, capacity: 0 };
|
SharedVectorHeader { refcount: atomic::AtomicIsize::new(-1), size: 0, capacity: 0 };
|
||||||
|
|
||||||
impl<T> Default for SharedVector<T> {
|
impl<T> Default for SharedVector<T> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue