Skip to content

Bidirectional pipe implementation#1

Open
GregoryLi360 wants to merge 12 commits into
mainfrom
feat/bidirectional-pipe
Open

Bidirectional pipe implementation#1
GregoryLi360 wants to merge 12 commits into
mainfrom
feat/bidirectional-pipe

Conversation

@GregoryLi360
Copy link
Copy Markdown
Contributor

@GregoryLi360 GregoryLi360 commented Apr 17, 2026

Summary

  • Lock-free SPSC bidirectional byte pipe over shared memory (no_std compatible)
  • RingHeader + RingData in ring.rs — monotonic cursors, Acquire/Release ordering, wrap-around handled internally
  • RingProducer / RingConsumer — non-blocking partial write/read with WouldBlock
  • BidirectionalPipe — composes two rings with interleaved layout for cache locality, Side::A / Side::B flip writer/reader wiring
  • SharedMemoryRegion — single unsafe entry point, safe API downstream
  • Interleaved memory layout [HeaderA][DataA][HeaderB][DataB] — headers adjacent to data, separated from each other to avoid false sharing
  • ring_size must be a multiple of 8 for header alignment, region must be 8-byte aligned
  • Zero-length read/write always returns Ok(0) regardless of ring state
  • 27 unit tests covering round-trips, wrap-around, partial read/write, fill/drain/refill, multi-lap, interleaved bidirectional, zero-length edge cases

Test plan

  • cargo test passes on fix (27/27)
  • Integration with control protocol

@GregoryLi360 GregoryLi360 marked this pull request as ready for review April 17, 2026 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant