Skip to content

Commit 885e342

Browse files
authored
Merge branch 'main' into separate-producer-consumer
2 parents 03b9774 + 02b7533 commit 885e342

File tree

17 files changed

+324
-481
lines changed

17 files changed

+324
-481
lines changed

.github/workflows/doctests.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
on:
22
push:
3-
branches: [ master ]
3+
branches: [ main ]
44
pull_request:
5-
branches: [ master ]
5+
branches: [ main ]
66

77
name: Documentation Tests
88

@@ -12,9 +12,6 @@ jobs:
1212
strategy:
1313
matrix:
1414
include:
15-
- rust: stable
16-
features: atomic
17-
nodefault: "--no-default-features"
1815
- rust: stable
1916
features: thumbv6
2017
nodefault: "--no-default-features"

.github/workflows/embedded-builds.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
on:
22
push:
3-
branches: [ master ]
3+
branches: [ main ]
44
pull_request:
5-
branches: [ master ]
5+
branches: [ main ]
66

77
name: Embedded Builds
88

@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
matrix:
1414
include:
15-
- feature: atomic
15+
- features: ""
1616
target: thumbv7em-none-eabihf
1717
rust: stable
1818
- feature: thumbv6

.github/workflows/fmt.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
on:
22
push:
3-
branches: [ master ]
3+
branches: [ main ]
44
pull_request:
5-
branches: [ master ]
5+
branches: [ main ]
66

77
name: Formatting check
88

.github/workflows/full-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
on:
22
push:
3-
branches: [ master ]
3+
branches: [ main ]
44
pull_request:
5-
branches: [ master ]
5+
branches: [ main ]
66

77
name: Integration Tests
88

.github/workflows/tsan-test.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
on:
22
push:
3-
branches: [ master ]
3+
branches: [ main ]
44
pull_request:
5-
branches: [ master ]
5+
branches: [ main ]
66

77
name: TSAN Integration Test
88

@@ -22,13 +22,14 @@ jobs:
2222
- uses: actions-rs/toolchain@v1
2323
with:
2424
profile: minimal
25+
components: rust-src
2526
toolchain: ${{ matrix.rust }}
2627

2728
- uses: actions-rs/cargo@v1
2829
with:
2930
command: test
3031
toolchain: nightly
31-
args: ${{ matrix.build }} --features=short-potato --manifest-path bbqtest/Cargo.toml --target x86_64-unknown-linux-gnu -- --nocapture
32+
args: ${{ matrix.build }} --features=short-potato --manifest-path bbqtest/Cargo.toml -Zbuild-std --target x86_64-unknown-linux-gnu -- --nocapture
3233
env:
3334
RUSTFLAGS: "-Z sanitizer=thread"
3435
RUST_TEST_THREADS: 1

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ block of contiguous memory, which can be filled (or emptied) by a DMA engine.
2323

2424
```rust
2525
// Create a buffer with six elements
26-
let bb: BBBuffer<U6> = BBBuffer::new();
26+
let bb: BBBuffer<6> = BBBuffer::new();
2727
let (mut prod, mut cons) = bb.try_split().unwrap();
2828

2929
// Request space for one byte
@@ -48,9 +48,11 @@ rgr.release(1);
4848

4949
## Static usage
5050

51-
```rust
51+
```rust, no_run
52+
use bbqueue::BBBuffer;
53+
5254
// Create a buffer with six elements
53-
static BB: BBBuffer<U6> = BBBuffer( ConstBBBuffer::new() );
55+
static BB: BBBuffer<6> = BBBuffer::new();
5456
5557
fn main() {
5658
// Split the bbqueue into producer and consumer halves.
@@ -90,10 +92,6 @@ By default BBQueue uses atomic operations which are available on most platforms.
9092
(mostly embedded) platforms atomic support is limited and with the default features you will get
9193
a compiler error about missing atomic methods.
9294

93-
This crate contains special support for Cortex-M0(+) targets with the `thumbv6` feature. By
94-
enabling the feature, unsupported atomic operations will be replaced with critical sections
95-
implemented by disabling interrupts. The critical sections are very short, a few instructions at
96-
most, so they should make no difference to most applications.
9795

9896
# License
9997

bbqtest/Cargo.toml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,15 @@ bounded-spsc-queue = { version = "0.4.0", optional = true }
1010

1111
[dependencies.bbqueue]
1212
path = "../core"
13-
features = ["std"]
1413

15-
[dependencies.generic-array]
16-
version = "0.12"
1714

1815
[dev-dependencies]
19-
rand = "0.6"
20-
criterion = "0.3"
21-
crossbeam-utils = "0.7"
22-
crossbeam = "0.7"
23-
heapless = "0.5"
24-
cfg-if = "0.1"
16+
rand = "0.8"
17+
criterion = "0.5"
18+
crossbeam-utils = "0.8"
19+
crossbeam = "0.8"
20+
heapless = "0.8"
21+
cfg-if = "1.0"
2522

2623
[[bench]]
2724
name = "benches"

bbqtest/src/benches.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use bbqueue::{consts::*, BBBuffer};
1+
use bbqueue::BBBuffer;
22
use criterion::{black_box, criterion_group, criterion_main, Criterion};
33
use std::cmp::min;
44

@@ -17,7 +17,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
1717

1818
c.bench_function("bbq 2048/4096", |bench| bench.iter(|| chunky(&data, 2048)));
1919

20-
let buffy: BBBuffer<U65536> = BBBuffer::new();
20+
let buffy: BBBuffer<65536> = BBBuffer::new();
2121
let (mut prod, mut cons) = buffy.try_split().unwrap();
2222

2323
c.bench_function("bbq 8192/65536", |bench| {
@@ -154,7 +154,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
154154

155155
use heapless::spsc::Queue;
156156

157-
let mut queue: Queue<[u8; 8192], U8> = Queue::new();
157+
let mut queue: Queue<[u8; 8192], 8> = Queue::new();
158158
let (mut prod, mut cons) = queue.split();
159159

160160
c.bench_function("heapless spsc::Queue 8192/65536", |bench| {
@@ -196,7 +196,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
196196

197197
use crossbeam_utils::thread;
198198
fn chunky(data: &[u8], chunksz: usize) {
199-
let buffy: BBBuffer<U4096> = BBBuffer::new();
199+
let buffy: BBBuffer<4096> = BBBuffer::new();
200200
let (mut prod, mut cons) = buffy.try_split().unwrap();
201201

202202
thread::scope(|sc| {

bbqtest/src/framed.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#[cfg(test)]
22
mod tests {
3-
use bbqueue::{consts::*, BBBuffer};
3+
use bbqueue::BBBuffer;
44

55
#[test]
66
fn frame_wrong_size() {
7-
let bb: BBBuffer<U256> = BBBuffer::new();
7+
let bb: BBBuffer<256> = BBBuffer::new();
88
let (mut prod, mut cons) = bb.try_split_framed().unwrap();
99

1010
// Create largeish grants
@@ -25,7 +25,7 @@ mod tests {
2525

2626
#[test]
2727
fn full_size() {
28-
let bb: BBBuffer<U256> = BBBuffer::new();
28+
let bb: BBBuffer<256> = BBBuffer::new();
2929
let (mut prod, mut cons) = bb.try_split_framed().unwrap();
3030
let mut ctr = 0;
3131

@@ -66,7 +66,7 @@ mod tests {
6666

6767
#[test]
6868
fn frame_overcommit() {
69-
let bb: BBBuffer<U256> = BBBuffer::new();
69+
let bb: BBBuffer<256> = BBBuffer::new();
7070
let (mut prod, mut cons) = bb.try_split_framed().unwrap();
7171

7272
// Create largeish grants
@@ -93,7 +93,7 @@ mod tests {
9393

9494
#[test]
9595
fn frame_undercommit() {
96-
let bb: BBBuffer<U512> = BBBuffer::new();
96+
let bb: BBBuffer<512> = BBBuffer::new();
9797
let (mut prod, mut cons) = bb.try_split_framed().unwrap();
9898

9999
for _ in 0..100_000 {
@@ -132,20 +132,24 @@ mod tests {
132132

133133
#[test]
134134
fn frame_auto_commit_release() {
135-
let bb: BBBuffer<U256> = BBBuffer::new();
135+
let bb: BBBuffer<256> = BBBuffer::new();
136136
let (mut prod, mut cons) = bb.try_split_framed().unwrap();
137137

138138
for _ in 0..100 {
139139
{
140-
let mut wgr = prod.grant(64).unwrap().into_auto_commit();
140+
let mut wgr = prod.grant(64).unwrap();
141+
wgr.to_commit(64);
141142
for (i, by) in wgr.iter_mut().enumerate() {
142143
*by = i as u8;
143144
}
144145
// drop
145146
}
146147

147148
{
148-
let rgr = cons.read().unwrap().into_auto_release();
149+
let mut rgr = cons.read().unwrap();
150+
rgr.auto_release(true);
151+
let rgr = rgr;
152+
149153
for (i, by) in rgr.iter().enumerate() {
150154
assert_eq!(*by, i as u8);
151155
}

0 commit comments

Comments
 (0)