Skip to content

Commit 354b249

Browse files
committed
remove non-idiomatic test
1 parent 48a0419 commit 354b249

File tree

1 file changed

+0
-40
lines changed

1 file changed

+0
-40
lines changed

src/io/README.mbt.md

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -556,46 +556,6 @@ async test "BufferedWriter::write_reader - buffered copy" {
556556
}
557557
```
558558

559-
## Working with Task Groups and Pipes
560-
561-
Most examples in this package lean on `@async.with_task_group` and `@io.pipe()` because they expose canonical `Reader` and `Writer` handles. The pattern scales to more complex topologies where multiple producers and consumers collaborate.
562-
563-
```moonbit
564-
///|
565-
async test "fan-out and fan-in" {
566-
@async.with_task_group(fn(root) {
567-
// Upstream producer pushes a header followed by the payload.
568-
let (intermediate_reader, intermediate_writer) = @io.pipe()
569-
root.spawn_bg(fn() {
570-
defer intermediate_writer.close()
571-
intermediate_writer.write(b"HDR")
572-
@async.sleep(10)
573-
intermediate_writer.write(b"PAYLOAD")
574-
})
575-
defer intermediate_reader.close()
576-
577-
// A downstream consumer receives the header via its own pipe.
578-
let (header_reader, header_writer) = @io.pipe()
579-
root.spawn_bg(fn() {
580-
defer header_writer.close()
581-
let header = intermediate_reader.read_exactly(3)
582-
header_writer.write(header)
583-
})
584-
root.spawn_bg(fn() {
585-
defer header_reader.close()
586-
inspect(header_reader.read_all().text(), content="HDR")
587-
})
588-
589-
// The original buffered reader still holds the payload.
590-
@async.sleep(30)
591-
let body = intermediate_reader.read_all().text()
592-
inspect(body, content="PAYLOAD")
593-
})
594-
}
595-
```
596-
597-
This example underscores how buffering plus task groups let you route data between multiple coroutines without copying or losing track of backpressure.
598-
599559
## Flow Control & Buffering Strategies
600560

601561
Efficient asynchronous I/O is mostly about balancing throughput and memory usage. Some guiding principles:

0 commit comments

Comments
 (0)