Saturday, July 20, 2024
HomeGolangDo we have to drain a buffered channel after closing it? -...

Do we have to drain a buffered channel after closing it? – Getting Assist


I’ve been working with buffered channels. I’ve stumbled upon a state of affairs the place buffered channel will likely be closed and the receiver of the channel terminates earlier than consuming all the weather within the buffer. So my query is will there be any problem concerning Rubbish Assortment of channel which ultimately results in reminiscence or useful resource leaks due to the not noted gadgets within the buffer? or some other considerations that I need to concentrate on?

The entire course of needs to be ended within the client, when it will get all the information from the producer. So possibly you possibly can add a “sign” channel to let client know that the producer is completed with its work.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments