Re: [go-nuts] Confused by test case of `singleflight`

2020-11-23 Thread 叶志辉
Thanks much for reply @lan On Monday, November 23, 2020 at 11:55:46 PM UTC+8 Ian Lance Taylor wrote: > On Mon, Nov 23, 2020 at 6:05 AM 叶志辉 wrote: > > > > A little confused by the test case of `singleflight` of > `internal/singleflight`. > > > > Which is the codes singleflight. > > > > 1. wg1 > >

Re: [go-nuts] Re: Local variable escapes to heap

2020-11-23 Thread jfcg...@gmail.com
I found this in runtime/chan.go: // Sends and receives on unbuffered or empty-buffered channels are the // only operations where one running goroutine writes to the stack of // another running goroutine. The GC assumes that stack writes only // happen when the goroutine is running and are only don

Re: [go-nuts] Confused by test case of `singleflight`

2020-11-23 Thread Ian Lance Taylor
On Mon, Nov 23, 2020 at 6:05 AM 叶志辉 wrote: > > A little confused by the test case of `singleflight` of > `internal/singleflight`. > > Which is the codes singleflight. > > 1. wg1 > > Purpose for wg1 is as commented as: > > // At least one goroutine is in fn now and all of them have at > // least r

[go-nuts] How to apply concurrency in golang to pass multiple app metrics to datadog

2020-11-23 Thread Shatabdi Pal
Hello, I have a requirement to create a datadog dashboard with application metrics. The app names are read from a config.toml. The code runs only for the first app provided in the toml file and never proceeds to the second app. The structure is a follows: *config.toml* application = ["app1",

[go-nuts] Confused by test case of `singleflight`

2020-11-23 Thread 叶志辉
A little confused by the test case of `singleflight` of `internal/singleflight`. Which is the codes singleflight . 1. wg1 Purpose for wg1 is as commented as: // At least one goroutine is in fn now

Re: [go-nuts] Re: Garbage Collector triggering when deleting an object

2020-11-23 Thread Robert Engels
Finalizers are essential in a highly concurrent system - otherwise you are doing manual resource management with automatic memory management (a resource) and its ugly and error prone. Even though they are no guaranteed to be called they work very well to manage shared resources. > On Nov 23,

Re: [go-nuts] Casting int to bool and the reverse for bit hacking ?

2020-11-23 Thread Aleksey Tulinov
Yeah, it's not the first time this question appears and it's not immediately obvious that Go compiler can do this optimization. IIRC someone asked for this optimization on Github and it's there, but Go doesn't allow bool to int conversion therefore it can't do this optimization implicitly, which i

[go-nuts] Re: Garbage Collector triggering when deleting an object

2020-11-23 Thread tokers
Are there any documents? On Monday, November 23, 2020 at 7:28:31 PM UTC+8 Tamás Gulácsi wrote: > There is a runtime.SetFinalizer, but it is not guaranteed to be run, > anytime. > The most idiomatic and safe solution is to have a Close() method on the Go > side, which frees the C side. > You may

[go-nuts] Re: Garbage Collector triggering when deleting an object

2020-11-23 Thread Tamás Gulácsi
There is a runtime.SetFinalizer, but it is not guaranteed to be run, anytime. The most idiomatic and safe solution is to have a Close() method on the Go side, which frees the C side. You may even add a Finalizer that panics if Close haven't been called before... tokers a következőt írta (2020.