qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Akihiko Odaki
Subject: Re: [PATCH v3 1/3] ui/cocoa: Run qemu_init in the main thread
Date: Sun, 17 Jul 2022 05:41:35 +0900
User-agent: Mozilla/5.0 (X11; Linux aarch64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0

On 2022/07/17 1:39, Paolo Bonzini wrote:
Il sab 16 lug 2022, 13:30 Akihiko Odaki <akihiko.odaki@gmail.com> 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 something like:

Yes, -[NSApplication terminate:] is thread-safe. Methods of
NSApplication handle dispatches to the main thread by themselves.


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/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html

Regards,
Akihiko Odaki


Paolo

Regards,
Akihiko Odaki


- here:

      /*
       * Nothing more to do in the QEMU thread, ask the application
       * to exit.
       */
      dispatch_async(dispatch_get_main_queue(), ^{
          [NSApp terminate: nil];
      });

- in verifyQuit:

      if([alert runModal] == NSAlertSecondButtonReturn) {
          with_iothread_lock(^{
              shutdown_action = SHUTDOWN_ACTION_POWEROFF;
              qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_UI);
          });
      }
      /* and just return void */

- applicationShouldTerminate: should be just

      if (qatomic_read(&qemu_main_terminating)) {
          return NSTerminateNow;
      } else {
          dispatch_async(dispatch_get_main_queue(), ^{
              [self verifyQuit];
          });
      }
      return NSTerminateCancel;

- applicationWillTerminate: can be just the qemu_thread_join

Paolo







reply via email to

[Prev in Thread] Current Thread [Next in Thread]