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?




On Friday, February 17, 2017 at 2:27:29 PM UTC-8, Ian Lance Taylor wrote:
>
> On Fri, Feb 17, 2017 at 1:34 PM,  <so.q...@gmail.com <javascript:>> 
> wrote: 
> > I'm not sure how to implement and use the Done function and its returned 
> > channel for contexts. 
> > https://golang.org/pkg/context/#Context 
> > 
> > The comments say to refer to https://blog.golang.org/pipelines, but I 
> didn't 
> > see any example there. 
> > 
> > Can you provide an example of how to implement a context that supports 
> > cancellation with Done? 
>
> You aren't really expected to write your own implementations of the 
> Context interface.  You are expected to start with context.Background 
> and modify that context using WithCancel, WithTimeout, WithValue, etc. 
>
> For example, if you write 
>     ctx, cancel := ctx.WithCancel(context.Background()) 
> Then ctx.Done() will be closed when you call cancel(). 
>
> 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