Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Rust

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
toolchain: ["stable"]
features: ["", "--features serde"]

steps:
- uses: actions/checkout@v4

- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}

- name: Install 32bit target
run: rustup target add i686-unknown-linux-musl
- name: Install wasm target
run: rustup target add wasm32v1-none
- name: Install miri
run: rustup component add --toolchain nightly-x86_64-unknown-linux-gnu miri
- name: Install no-std-check
run: cargo install cargo-no-std-check

- name: Build
run: cargo build --verbose ${{ matrix.features }}
- name: Build-32bit
run: cargo build --verbose --target i686-unknown-linux-musl ${{ matrix.features }}
- name: Build-wasm
run: cargo build --verbose --target wasm32v1-none ${{ matrix.features }}

- name: Test
run: cargo test --verbose ${{ matrix.features }}
- name: Test-32bit
run: cargo test --verbose --target i686-unknown-linux-musl ${{ matrix.features }}
- name: Check-wasm
run: cargo check --verbose --target wasm32v1-none ${{ matrix.features }}

- name: Clippy
run: cargo clippy ${{ matrix.features }} -- -D warnings --verbose

- name: Miri
run: cargo +nightly miri test --verbose ${{ matrix.features }}

- name: NoStd
run: cargo +nightly no-std-check ${{ matrix.features }}
26 changes: 13 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "orx-concurrent-vec"
version = "3.5.0"
edition = "2021"
version = "3.6.0"
edition = "2024"
authors = ["orxfun <orx.ugur.arikan@gmail.com>"]
description = "A thread-safe, efficient and lock-free vector allowing concurrent grow, read and update operations."
license = "MIT OR Apache-2.0"
Expand All @@ -10,24 +10,24 @@ keywords = ["concurrency", "vec", "data-structures", "atomic", "lock-free"]
categories = ["data-structures", "concurrency", "rust-patterns", "no-std"]

[dependencies]
orx-pseudo-default = { version = "2.0.0", default-features = false }
orx-pinned-vec = "3.15"
orx-fixed-vec = "3.15"
orx-split-vec = "3.15"
orx-pinned-concurrent-col = "2.12"
orx-concurrent-option = "1.4"
serde = { version = "1.0.217", optional = true, default-features = false }
orx-pseudo-default = { version = "2.1.0", default-features = false }
orx-pinned-vec = "3.16.0"
orx-fixed-vec = "3.16.0"
orx-split-vec = "3.16.0"
orx-pinned-concurrent-col = "2.13.0"
orx-concurrent-option = "1.5.0"
serde = { version = "1.0.219", optional = true, default-features = false }

[dev-dependencies]
append-only-vec = "0.1.7"
boxcar = "0.2.8"
clap = { version = "4.5.28", features = ["derive"] }
boxcar = "0.2.11"
clap = { version = "4.5.35", features = ["derive"] }
criterion = "0.5.1"
orx-iterable = "1.2.0"
orx-iterable = { version = "1.3.0", default-features = false }
rand = "0.9.0"
rand_chacha = "0.9.0"
rayon = "1.10.0"
serde_json = { version = "1.0.138", default-features = false, features = [
serde_json = { version = "1.0.140", default-features = false, features = [
"std",
] }
test-case = "3.3.1"
Expand Down
6 changes: 3 additions & 3 deletions src/concurrent_slice/unsafe_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ where
/// assert_eq!(averages.len(), 10);
/// ```
pub unsafe fn get_ref(&self, i: usize) -> Option<&T> {
self.idx(i).and_then(|i| self.vec.get_ref(i))
self.idx(i).and_then(|i| unsafe { self.vec.get_ref(i) })
}

/// Returns an iterator to references of elements of the vec.
Expand Down Expand Up @@ -345,7 +345,7 @@ where
/// assert_eq!(&vec, &['a', 'x', 'c', 'd']);
/// ```
pub unsafe fn get_mut(&self, i: usize) -> Option<&mut T> {
self.idx(i).and_then(|i| self.vec.get_mut(i))
self.idx(i).and_then(|i| unsafe { self.vec.get_mut(i) })
}

/// Returns an iterator to mutable references of elements of the vec.
Expand Down Expand Up @@ -401,6 +401,6 @@ where
pub unsafe fn iter_mut(&self) -> impl Iterator<Item = &mut T> {
let b = self.a + self.len;
unsafe { self.vec.core.iter_over_range(self.a..b) }
.flat_map(|x| x.0.get_raw_mut().map(|p| &mut *p))
.flat_map(|x| x.0.get_raw_mut().map(|p| unsafe { &mut *p }))
}
}
2 changes: 1 addition & 1 deletion src/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl<T> ConcurrentVec<T, SplitVec<ConcurrentElement<T>, Doubling>> {

/// Creates a new concurrent bag by creating and wrapping up a new [`SplitVec<T, Doubling>`](https://docs.rs/orx-split-vec/latest/orx_split_vec/struct.Doubling.html) as the underlying storage.
pub fn with_doubling_growth() -> Self {
Self::new_from_pinned(SplitVec::with_doubling_growth_and_fragments_capacity(32))
Self::new_from_pinned(SplitVec::with_doubling_growth_and_max_concurrent_capacity())
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/unsafe_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ where
pub unsafe fn get_ref(&self, i: usize) -> Option<&T> {
match i < self.reserved_len() {
true => {
let maybe = self.core.get(i);
maybe.and_then(|x| x.0.as_ref_with_order(Ordering::SeqCst))
let maybe = unsafe { self.core.get(i) };
maybe.and_then(|x| unsafe { x.0.as_ref_with_order(Ordering::SeqCst) })
}
false => None,
}
Expand Down Expand Up @@ -269,7 +269,7 @@ where
/// assert_eq!(averages.len(), 10);
/// ```
pub unsafe fn iter_ref(&self) -> impl Iterator<Item = &T> {
let x = self.core.iter(self.reserved_len());
let x = unsafe { self.core.iter(self.reserved_len()) };
x.flat_map(|x| unsafe { x.0.as_ref_with_order(Ordering::SeqCst) })
}

Expand Down Expand Up @@ -363,8 +363,8 @@ where
pub unsafe fn get_mut(&self, i: usize) -> Option<&mut T> {
match i < self.reserved_len() {
true => {
let elem = self.core.get(i);
elem.and_then(|option| option.0.get_raw_mut().map(|p| &mut *p))
let elem = unsafe { self.core.get(i) };
elem.and_then(|option| option.0.get_raw_mut().map(|p| unsafe { &mut *p }))
}
false => None,
}
Expand Down Expand Up @@ -419,7 +419,7 @@ where
/// assert_eq!(&vec, &[0, 2, 4, 6]);
/// ```
pub unsafe fn iter_mut(&self) -> impl Iterator<Item = &mut T> {
let x = self.core.iter(self.reserved_len());
x.flat_map(|x| x.0.get_raw_mut().map(|p| &mut *p))
let x = unsafe { self.core.iter(self.reserved_len()) };
x.flat_map(|x| x.0.get_raw_mut().map(|p| unsafe { &mut *p }))
}
}
6 changes: 3 additions & 3 deletions tests/concurrent_read_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,12 @@ where
#[cfg(not(miri))]
#[test_matrix([500, 1_000, 10_000])]
fn concurrent_read_write(num_items_per_thread: usize) {
let pinned = SplitVec::with_doubling_growth_and_fragments_capacity(32);
let pinned = SplitVec::with_doubling_growth_and_max_concurrent_capacity();
spawn(pinned, NUM_GROWERS, NUM_USERS, num_items_per_thread);
}

#[test_matrix([250])]
#[test_matrix([100])]
fn miri_concurrent_read_write(num_items_per_thread: usize) {
let pinned = SplitVec::with_doubling_growth_and_fragments_capacity(32);
let pinned = SplitVec::with_doubling_growth_and_max_concurrent_capacity();
spawn(pinned, NUM_GROWERS, NUM_USERS, num_items_per_thread);
}