panjf2000 / ants

🐜🐜🐜 ants is the most powerful and reliable pooling solution for Go.
https://ants.andypan.me/
MIT License
12.69k stars 1.36k forks source link

[Question]: ants.Submit() question #294

Closed hiqsociety closed 1 year ago

hiqsociety commented 1 year ago

Questions with details

is this ok? will ipAddrStr be sent inside ants.Submit's somefunc()? i'm worried if ipAddrString will be "" is the below the right way to do it?

func main() {
   ... //ipAddr

   go somefunc2(ipAddr)
}

func somefunc2(ipAddr netip.Addr) {
ipAddrStr := ipAddr.String()

ants.Submit(func() {
 somefunc(ipAddrStr)
})
}

Code snippets (optional)

No response

panjf2000 commented 1 year ago

Why would the ipAddrString be empty?

hiqsociety commented 1 year ago
  1. @panjf2000 will the value of ipAddrStr change?

  2. what about this?

func main() { ... //ipAddr

ants.Submit(func() { somefunc2(ipAddr.String()) }) }

func somefunc2(ipAddrStr string) { ants.Submit(func() { somefunc(ipAddrStr) }) }

panjf2000 commented 1 year ago

Again, why would the value change? I don't get your point.

hiqsociety commented 1 year ago

@panjf2000 maybe it's my code. thank you for the verification! it's mix and matching other go routines. i'll just use yours. thx!