API is ambiguous
• Does it start a new goroutine every time
Start() is called?
• Does it error from the second one?
Only start one?
• Maybe Start() can return an error if it
has already been started
• Bonus points: can it be re-entrant?
• Requires state synchronization
ctx, cancel := context.WithTimeout(ctxbg, delay)
defer cancel()
go obj1.Run(ctx) // use a diff. ctx if need be
go obj2.Run(ctx) // re-entrant! yay!
go obj3.Run(ctx)
Explicit semantics
Prediction/Recommendation
• Almost everything that can (1) block or (2) spawn a
goroutine will support context.Context very soon.
• You should use context.Context for anything that
blocks!