The code (and even similar using channels) is highly inefficient. You need to understand the expected collision rate because if it’s low (expected) paying the lock cost on every operation is wasteful. Better to partition the work based on the token (hash N) and avoid the lock operations.
You can also make it far more efficient by an atomic bitset with page locking. > On Apr 4, 2020, at 9:26 AM, Tamás Gulácsi <tgulacs...@gmail.com> wrote: > > Check out https://pkg.go.dev/golang.org/x/sync/singleflight ! > > -- > 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/aab893a3-7370-4682-8ba8-27efff919791%40googlegroups.com. -- 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/DB7369FD-C840-4D6F-97D3-B25CDAD045AB%40ix.netcom.com.