Re: [go-nuts] Is this a safe way to block main thread but not main goroutine?

2020-04-29 Thread Marcin Romaszewicz
As Thomas said, this will work for sure, though, and doesn't require any manual setup, and you don't need to do funny business with CGO. func main() { go doAllYourOtherStuff() blockOnDarwinEventLoop() } Done. On Wed, Apr 29, 2020 at 1:44 PM Akhil Indurti wrote: > I want to mirror (or

Re: [go-nuts] Is this a safe way to block main thread but not main goroutine?

2020-04-29 Thread Akhil Indurti
I want to mirror (or control) the event loop inside the main goroutine. The main goroutine should be the one to block for events. Plus, as long as it's safe, it doesn't seem needlessly complex to me. On Wednesday, April 29, 2020 at 4:38:27 PM UTC-4, Thomas Bushnell, BSG wrote: > > That seems

Re: [go-nuts] Is this a safe way to block main thread but not main goroutine?

2020-04-29 Thread 'Thomas Bushnell, BSG' via golang-nuts
That seems needlessly complex. Why not just skip the weird init, and just have main do a go to the thing you want to be not on the main thread, and let the main thread do its thing? On Wed, Apr 29, 2020 at 4:19 PM Akhil Indurti wrote: > I want to run the main goroutine on another thread besides

[go-nuts] Is this a safe way to block main thread but not main goroutine?

2020-04-29 Thread Akhil Indurti
I want to run the main goroutine on another thread besides the main thread, so that the main thread can block in darwin UI code. Is this a safe way to do it? package main /* #include #include void block() { printf("Blocking main thread? %d\n", pthread_main_np()); while(1); }