|
|
|
|
|
by Groxx
1698 days ago
|
|
It's a semantically better thread-local var[1] + a slightly more one-way thread interruption of sorts[2]. It's a performance nightmare when you put too many layers on it, but to some degree: meh. If that's your performance bottleneck, you have many options. [1]: In that it's request-local and explicit, which makes it both clearer and much easier to control. For pure "optimize for fewer memory movements or cross-thread locks" purposes, go has nothing, you have to trust the runtime to schedule efficiently. Except maybe runtime.LockOSThread(). [2]: You can always make a new context that's not cancelled, or just not look at the Done channel. But by accident you get better cancellation behavior than e.g. java's thread interruption, because everyone still uses `catch (Exception e) { println(e) }` despite decades of education to not do so. |
|