8000 GitHub - fredwangwang/go-unboundedchannel: An elastically grow channel impl for golang, used in cases where sudden backpressure cannot be afford to be blocked or dropped.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

An elastically grow channel impl for golang, used in cases where sudden backpressure cannot be afford to be blocked or dropped.

License

Notifications You must be signed in to change notification settings

fredwangwang/go-unboundedchannel

Repository files navigation

go-unboundedchannel

An elastically grow channel impl for golang, used in cases where sudden backpressure cannot be afford to be blocked or dropped.

Advantage over a large buffered channel

buffered channel actually consumes memory when created. In cases where you anticipate mostly only small buffer requrired, but need to account for sudden expansion in magnitude, it would be wasteful to allocate all those buffers up front. Instead, unbounded channel will start with a initial buffer that suits most of the cases, and elastically grow if needed.

Disadvantage over buffered channel

The ealstically growing feature is powered by a background goroutine, which means if the unbounded channel is not closed and drained properly, it could cause goroutine and memory leak.

This can be remediated using NewUnboundedChanWithFinalizer to automatically cleanup the channel if no external refernce to the channel exists.

About

An elastically grow channel impl for golang, used in cases where sudden backpressure cannot be afford to be blocked or dropped.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0