qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Akihiko Odaki <akihiko.odaki@gmail.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, "Peter Maydell" <peter.maydell@linaro.org>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Emanuele Giuseppe Esposito" <eesposit@redhat.com>,
	"Kevin Wolf" <kwolf@redhat.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: Re: [PATCH v3 1/3] ui/cocoa: Run qemu_init in the main thread
Date: Sat, 16 Jul 2022 20:30:25 +0900	[thread overview]
Message-ID: <2704624f-6e89-1938-e54f-f5ddcb0daf6e@gmail.com> (raw)
In-Reply-To: <675d98f9-9045-5bf9-27c7-c2d5cb0b088d@redhat.com>

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.

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	other threads:[~2022-07-16 11:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-15 13:47 [PATCH v3 0/3] ui/cocoa: Run qemu_init in the main thread Akihiko Odaki
2022-07-15 13:47 ` [PATCH v3 1/3] " Akihiko Odaki
2022-07-16 10:16   ` Paolo Bonzini
2022-07-16 11:30     ` Akihiko Odaki [this message]
2022-07-16 16:39       ` Paolo Bonzini
2022-07-16 20:41         ` Akihiko Odaki
2022-07-17  3:18           ` Paolo Bonzini
2022-07-15 13:47 ` [PATCH v3 2/3] Revert "main-loop: Disable block backend global state assertion on Cocoa" Akihiko Odaki
2022-07-15 13:47 ` [PATCH v3 3/3] meson: Allow to enable gtk and sdl while cocoa is enabled Akihiko Odaki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2704624f-6e89-1938-e54f-f5ddcb0daf6e@gmail.com \
    --to=akihiko.odaki@gmail.com \
    --cc=eesposit@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).