Re: [PATCH v3 1/3] ui/cocoa: Run qemu_init in the main thread

2022-07-16 Thread Paolo Bonzini
Il sab 16 lug 2022, 22:42 Akihiko Odaki ha scritto: > > Is this documented anywhere? > > Thread-unsafe classes (and more importantly, main thread only classes) > are rather exceptional, and they are listed at: > > https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Multithr

Re: [PATCH v3 1/3] ui/cocoa: Run qemu_init in the main thread

2022-07-16 Thread Akihiko Odaki
On 2022/07/17 1:39, Paolo Bonzini wrote: Il sab 16 lug 2022, 13:30 Akihiko Odaki ha scritto: On 2022/07/16 19:16, Paolo Bonzini wrote: On 7/15/22 15:47, Akihiko Odaki wrote: static void *call_qemu_main(void *opaque) { ... +[NSApp terminate:nil]; Is this thread-safe? I think

Re: [PATCH v3 1/3] ui/cocoa: Run qemu_init in the main thread

2022-07-16 Thread Paolo Bonzini
Il sab 16 lug 2022, 13:30 Akihiko Odaki ha scritto: > On 2022/07/16 19:16, Paolo Bonzini wrote: > > On 7/15/22 15:47, Akihiko Odaki wrote: > >> static void *call_qemu_main(void *opaque) > >> { > >> ... > >> +[NSApp terminate:nil]; > > Is this thread-safe? I think it should be someth

Re: [PATCH v3 1/3] ui/cocoa: Run qemu_init in the main thread

2022-07-16 Thread Akihiko Odaki
On 2022/07/16 19:16, Paolo Bonzini wrote: On 7/15/22 15:47, Akihiko Odaki wrote:   static void *call_qemu_main(void *opaque)   { ... +    [NSApp terminate:nil]; Is this thread-safe?  I think it should be something like: Yes, -[NSApplication terminate:] is thread-safe. Methods of NSAppli

Re: [PATCH v3 1/3] ui/cocoa: Run qemu_init in the main thread

2022-07-16 Thread Paolo Bonzini
On 7/15/22 15:47, Akihiko Odaki wrote: static void *call_qemu_main(void *opaque) { ... +[NSApp terminate:nil]; Is this thread-safe? I think it should be something like: - here: /* * Nothing more to do in the QEMU thread, ask the application * to exit. */

[PATCH v3 1/3] ui/cocoa: Run qemu_init in the main thread

2022-07-15 Thread Akihiko Odaki
This work is based on: https://patchew.org/QEMU/20220317125534.38706-1-philippe.mathieu.da...@gmail.com/ Simplify the initialization dance by running qemu_init() in the main thread before the Cocoa event loop starts. The secondary thread only runs only qemu_main_loop() and qemu_cleanup(). This fi