qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: Liviu Ionescu <ilg@livius.net>
Cc: QEMU Developer <Qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] experience with SDL2, event loop & main thread
Date: Mon, 12 Dec 2016 11:35:12 +0800	[thread overview]
Message-ID: <20161212033512.GA3725@lemon> (raw)
In-Reply-To: <6BBB3038-0389-4221-9A41-63800F3FF514@livius.net>

On Sat, 12/10 18:16, Liviu Ionescu wrote:
> conclusions:
> 
> - the graphical event loop and all graphical primitives must be called from the main thread context
> - in qemu this is not possible directly; an inefficient but functional
> solution uses a timer programmed to call a function every few milliseconds, to
> poll the event loop. (if the qemu I/O event loop is executed on the main
> thread, the timer function will be called from the main thread context)

Isn't it possible to notify the main thread with an EventNotifier and process
the deferred events in its handler?

Fam

> - all graphical operations initiated by the all other thread (like the emulator thread), must be deferred (in SDL using user events) to the graphical event loop
> - a function to run graphical destruction must be registered with atexit()
> - only the main thread can call exit(), to ensure the destruction functions are not called from other threads
> - exiting from other threads must be also deferred to the main thread, possibly with unlocking a mutex.
> 
> 
> I hope that helps,
> 
> Liviu
> 
> 
> 
> 
> 
> 
> 

  reply	other threads:[~2016-12-12  3:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-10 16:16 [Qemu-devel] experience with SDL2, event loop & main thread Liviu Ionescu
2016-12-12  3:35 ` Fam Zheng [this message]
2016-12-12  7:18   ` Liviu Ionescu
2016-12-12  7:39     ` Fam Zheng
2016-12-12  7:43       ` Liviu Ionescu
2016-12-12  9:39         ` Fam Zheng
2016-12-12 10:20           ` Liviu Ionescu
2016-12-12 10:36             ` Fam Zheng
2016-12-12 10:42               ` Daniel P. Berrange
2016-12-12 11:27               ` Liviu Ionescu
2016-12-12 12:28                 ` Fam Zheng
2016-12-12 13:22                   ` Liviu Ionescu
2016-12-12 14:51                     ` Fam Zheng
2016-12-12 15:07                       ` Liviu Ionescu
2016-12-13  7:04                         ` Fam Zheng
2016-12-13  7:21                           ` Liviu Ionescu

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=20161212033512.GA3725@lemon \
    --to=famz@redhat.com \
    --cc=Qemu-devel@nongnu.org \
    --cc=ilg@livius.net \
    /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).