@@ -54,9 +54,6 @@ pub struct BBBuffer<const N: usize> {
54
54
/// Is there an active write grant?
55
55
write_in_progress : AtomicBool ,
56
56
57
- /// Have we already split?
58
- already_split : AtomicBool ,
59
-
60
57
/// Whether we have split the producer and/or consumer parts off.
61
58
///
62
59
/// See the `BIT_PRODUCER` and `BIT_CONSUMER` bits which define what parts have been split off.
@@ -160,7 +157,7 @@ impl<'a, const N: usize> BBBuffer<N> {
160
157
/// while splitting.
161
158
pub fn try_take_producer ( & ' a self ) -> Result < Producer < ' a , N > > {
162
159
// Set producer taken bit, error if already set
163
- if self . 0 . split_prod_cons . fetch_or ( BIT_PRODUCER , AcqRel ) & BIT_PRODUCER > 0 {
160
+ if self . split_prod_cons . fetch_or ( BIT_PRODUCER , AcqRel ) & BIT_PRODUCER > 0 {
164
161
return Err ( Error :: AlreadySplit ) ;
165
162
}
166
163
@@ -169,7 +166,7 @@ impl<'a, const N: usize> BBBuffer<N> {
169
166
// // Explicitly zero the data to avoid undefined behavior.
170
167
// // This is required, because we hand out references to the buffers,
171
168
// // which mean that creating them as references is technically UB for now
172
- // let mu_ptr = self.0. buf.get();
169
+ // let mu_ptr = self.buf.get();
173
170
// (*mu_ptr).as_mut_ptr().write_bytes(0u8, 1);
174
171
175
172
let nn1 = NonNull :: new_unchecked ( self as * const _ as * mut _ ) ;
@@ -194,7 +191,7 @@ impl<'a, const N: usize> BBBuffer<N> {
194
191
/// while splitting.
195
192
pub fn try_take_consumer ( & ' a self ) -> Result < Consumer < ' a , N > > {
196
193
// Set producer taken bit, error if already set
197
- if self . 0 . split_prod_cons . fetch_or ( BIT_CONSUMER , AcqRel ) & BIT_CONSUMER > 0 {
194
+ if self . split_prod_cons . fetch_or ( BIT_CONSUMER , AcqRel ) & BIT_CONSUMER > 0 {
198
195
return Err ( Error :: AlreadySplit ) ;
199
196
}
200
197
@@ -203,7 +200,7 @@ impl<'a, const N: usize> BBBuffer<N> {
203
200
// // Explicitly zero the data to avoid undefined behavior.
204
201
// // This is required, because we hand out references to the buffers,
205
202
// // which mean that creating them as references is technically UB for now
206
- // let mu_ptr = self.0. buf.get();
203
+ // let mu_ptr = self.buf.get();
207
204
// (*mu_ptr).as_mut_ptr().write_bytes(0u8, 1);
208
205
209
206
let nn1 = NonNull :: new_unchecked ( self as * const _ as * mut _ ) ;
@@ -361,8 +358,8 @@ impl<'a, const N: usize> BBBuffer<N> {
361
358
return Err ( prod) ;
362
359
}
363
360
364
- let wr_in_progress = self . 0 . write_in_progress . load ( Acquire ) ;
365
- let rd_in_progress = self . 0 . read_in_progress . load ( Acquire ) ;
361
+ let wr_in_progress = self . write_in_progress . load ( Acquire ) ;
362
+ let rd_in_progress = self . read_in_progress . load ( Acquire ) ;
366
363
367
364
if wr_in_progress || rd_in_progress {
368
365
// Can't release, active grant(s) in progress
@@ -373,13 +370,13 @@ impl<'a, const N: usize> BBBuffer<N> {
373
370
drop ( prod) ;
374
371
375
372
// Re-initialize the buffer (not totally needed, but nice to do)
376
- self . 0 . write . store ( 0 , Release ) ;
377
- self . 0 . read . store ( 0 , Release ) ;
378
- self . 0 . reserve . store ( 0 , Release ) ;
379
- self . 0 . last . store ( 0 , Release ) ;
373
+ self . write . store ( 0 , Release ) ;
374
+ self . read . store ( 0 , Release ) ;
375
+ self . reserve . store ( 0 , Release ) ;
376
+ self . last . store ( 0 , Release ) ;
380
377
381
378
// Mark the buffer as ready to retake producer
382
- self . 0 . split_prod_cons . fetch_and ( !BIT_PRODUCER , Release ) ;
379
+ self . split_prod_cons . fetch_and ( !BIT_PRODUCER , Release ) ;
383
380
384
381
Ok ( ( ) )
385
382
}
@@ -432,8 +429,8 @@ impl<'a, const N: usize> BBBuffer<N> {
432
429
return Err ( cons) ;
433
430
}
434
431
435
- let wr_in_progress = self . 0 . write_in_progress . load ( Acquire ) ;
436
- let rd_in_progress = self . 0 . read_in_progress . load ( Acquire ) ;
432
+ let wr_in_progress = self . write_in_progress . load ( Acquire ) ;
433
+ let rd_in_progress = self . read_in_progress . load ( Acquire ) ;
437
434
438
435
if wr_in_progress || rd_in_progress {
439
436
// Can't release, active grant(s) in progress
@@ -444,13 +441,13 @@ impl<'a, const N: usize> BBBuffer<N> {
444
441
drop ( cons) ;
445
442
446
443
// Re-initialize the buffer (not totally needed, but nice to do)
447
- self . 0 . write . store ( 0 , Release ) ;
448
- self . 0 . read . store ( 0 , Release ) ;
449
- self . 0 . reserve . store ( 0 , Release ) ;
450
- self . 0 . last . store ( 0 , Release ) ;
444
+ self . write . store ( 0 , Release ) ;
445
+ self . read . store ( 0 , Release ) ;
446
+ self . reserve . store ( 0 , Release ) ;
447
+ self . last . store ( 0 , Release ) ;
451
448
452
449
// Mark the buffer as ready to retake consumer
453
- self . 0 . split_prod_cons . fetch_and ( !BIT_CONSUMER , Release ) ;
450
+ self . split_prod_cons . fetch_and ( !BIT_CONSUMER , Release ) ;
454
451
455
452
Ok ( ( ) )
456
453
}
0 commit comments