From 5f9ed297b55a47a09f088750838327aa4dbb858d Mon Sep 17 00:00:00 2001 From: kinggo Date: Sun, 18 Dec 2022 17:30:20 +0800 Subject: [PATCH] doc: optimize the comment of the Request.Done method --- server.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server.go b/server.go index 0be703c77d..6148384b17 100644 --- a/server.go +++ b/server.go @@ -2697,6 +2697,9 @@ func (ctx *RequestCtx) Deadline() (deadline time.Time, ok bool) { // Done returns a channel that's closed when work done on behalf of this // context should be canceled. Done may return nil if this context can // never be canceled. Successive calls to Done return the same value. +// +// Note: Because creating a new channel for every request is just too expensive so +// RequestCtx.s.done is only closed when the server is shutting down func (ctx *RequestCtx) Done() <-chan struct{} { return ctx.s.done } @@ -2707,6 +2710,9 @@ func (ctx *RequestCtx) Done() <-chan struct{} { // If Done is closed, Err returns a non-nil error explaining why: // Canceled if the context was canceled (via server Shutdown) // or DeadlineExceeded if the context's deadline passed. +// +// Note: Because creating a new channel for every request is just too expensive so +// RequestCtx.s.done is only closed when the server is shutting down func (ctx *RequestCtx) Err() error { select { case <-ctx.s.done: