ctx.Err() really simplifies the whole process. I'll use it to optimize my 
task executor, thanks.

On Wednesday, 12 January 2022 at 10:05:57 UTC Brian Candler wrote:
>
>> On Wednesday, 12 January 2022 at 08:41:23 UTC lege...@gmail.com wrote:
>>
>>> What I think it's not so good is that I must add the select at all the 
>>> places the goroutine is waiting or looping
>>>
>>
>> I don't think you do.  Well-behaved functions which take a Context will 
>> return with an error if the context is cancelled - and presumably you're 
>> already checking for an error, so it doesn't make any difference.
>>
>
Because I didn't use context as parameters when I execute my tasks before, 
so I need to add it into some functions and check ctx.Err() when necessary, 
It will take some work, but I believe it's the best method I can think of 
so far based on the discussion above.

I can understand that some blocking points in the I/O process cannot be 
canceled, this is an acceptable delay.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ef8b9e97-2de5-4656-a709-4bf9cb622be5n%40googlegroups.com.

Reply via email to