On 2016-10-28 13:32, roger peppe wrote:
On 28 October 2016 at 11:03, Nick Patavalis <nick.patava...@gmail.com> wrote:
In fact the worker "w" is a single-use thing much like a context.
Yes, that's right. The main difference from a context is that a context provides
no way to know when things shut down. This, I think, is by design - things
like ErrGroup provide that functionality when needed.
... or just when Serve() exits.
So ... bottom line ... defining Server objects as one-shot/single-use
allows you to define the Kill()/Shutdown() semantics to simply exhaust
that single-use. (an being idempotent) ... making it irrelevant whether
the server has actually been started, since any call to Serve() would
just exit immediately when the Server has been invalidated by
Kill()/Shutdown()
This would then require a 3rd method Reset() to make the server restartable.
Not having servers being single-use would mean you don't know which
Serve() invocation you are killing and you would solve the question of
whether to queue Shutdown() events or throw some of them away... and
more problematic... a caller of Kill()/Shutdown() will have to have
someway to know whether it makes sense to Wait() for a Serve() - and
which Serve() that is.
Context solves that problem, since it gives an explicit reference to
each Serve() invocation from the outside.
Is that a fair summary?
Btw: Nick ... I've created an issued based on this discussion with my
code, since there's clearly something to think about here.
/Peter
--
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.