On Tue, Feb 21, 2017 at 11:15 AM, Thomas Bushnell, BSG
<tbushn...@google.com> wrote:
> On Mon, Feb 20, 2017 at 11:42 AM Ian Lance Taylor <i...@golang.org> wrote:
>>
>> On Sun, Feb 19, 2017 at 2:57 PM,  <so.qu...@gmail.com> wrote:
>> > Thanks, I see you build it up with decorators on a standard prototype.
>> > For example: https://play.golang.org/p/PJy5lE9QqF
>> >
>> > So context.Done is a convenience function for those that require it?
>> > Otherwise a context will expire after it leaves scope, so Done does not
>> > need
>> > to be called?
>>
>> Cancelling the context just marks the context as cancelled.  It does
>> not actually stop any goroutines using the context.  Those goroutines
>> must themselves periodically check the context to see whether it has
>> been cancelled, and, if so, stop working.  They do that by calling
>> either the Done or Err method; it's much more common to call the Done
>> method (and check whether the channel is closed).
>
>
> Calling the Err() method to see if the context has been cancelled is
> incorrect.

...

> "Err's return value is unspecified before Done is closed."

Hmmm, that text is not in the version of the context package included
in the Go standard library.  Perhaps it should be.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to