go_channels 0.2.1
go_channels: ^0.2.1 copied to clipboard
Go-style concurrency for Dart: typed channels, a faithful select over many channel operations, and structured task scopes with cooperative cancellation.
0.2.1 #
-
Add
benchmark/capacity_benchmark.dartand document what buffer capacity actually buys. Moving 200,000 values from one task to another, every buffered size (1, 16, 256, 4096) lands within a few percent of every other and about 10% above the unbuffered rendezvous, and draining throughselectmeasured slightly faster than a directreceive. Capacity is a backpressure decision, not a throughput one, and the README now says so with the chart.Two things the benchmark had to get right to be worth reading: the plain case drains with
receiveOrrather thanch.stream, because the stream wraps every value in aStreamControllerevent and would have measured Dart's stream machinery instead of the channel; and every case asserts it moved all 200,000 values, so the rows are comparable. The claim that a waiting rendezvous does not block the isolate is measured too — a 1 ms timer fires 20 times in 20 ms with asendoutstanding.
0.2.0 #
- Seal the public types.
Channel,SelectCases,TaskScope,CancelToken,ChannelClosedErrorandCancelledExceptionare nowfinal. None is meant to be subtyped — a channel's guarantees come from its implementation, not from an interface — and doing this now, while the package is young, keeps every future field from being a breaking change for a subclasser later. Nothing in the package, its tests, its example or its benchmark subtypes any of them. No behaviour change.
0.1.1 #
First pub.dev release. The package was developed under the name channels,
which pub.dev rejects as too similar to the existing channel package, so it
is published as go_channels. The import is
package:go_channels/go_channels.dart; the API is unchanged.
- Add a diagram to the README, and declare it as a pub.dev screenshot, showing
the one thing that separates an unbuffered channel from a buffered one: when
sendcompletes. Unbuffered rendezvous —sendfinishes at the receive; buffered letssendreturn while the buffer has room, and blocks only when it is full.
0.1.0 #
- Initial release.
Channel<T>: buffered and unbuffered channels withsend,receive,receiveOr(Go-stylevalue, ok), astreamview, andclose.select: waits on several channel receives/sends at once and runs exactly one, withonDefault(non-blocking) andonTimeoutbranches; random choice among ready branches for fairness.- Structured concurrency:
withTaskScopeandwaitAllrun a group of tasks fail-fast,CancelTokenprovides cooperative cancellation, andwithTimeoutcancels on a deadline.