How to create client in child thread
gschwind at gnu-log.net
Wed Jun 15 20:24:19 UTC 2016
The reply from Pekka is about compositor using a client to make the
rendering, but I not sure this is what you asking for.
Are you talking about building a compositor ? It look like you are
making a wayland client that try to delegate the drawing to a thread. Is
it what you want to do ?
On 15/06/2016 09:24, Pekka Paalanen wrote:
> On Wed, 15 Jun 2016 12:34:06 +0800 (CST)
> 袁嘉伟 <yuanjw1025 at 163.com> wrote:
>> Hi, All: I try to create the client and draw it in child
>> thread failed. If calling functions from child thread, it will block.
>> So I want to know whether wayland(v1.9) supports to create and redraw
>> the client in child thread. Perhaps anyone could tell me how to
>> create a client in child thread.It's better to give me some sample
>> code. Thanks.
> first of all, I would recommend not doing that. Figure out if you
> really cannot achieve what you want as a separate process instead of a
> thread in the compositor process.
> There is no specific support for making a client in a thread. You have
> to write the client part as if it was a separate process anyway. This
> means you have to have an event loop in the client thread, that polls
> for the Wayland connection fd and anything else it might need to
> respond to.
> Using a simple mutex locking scheme to protect data when accessed from
> a different thread runs a risk of deadlocks if not done exactly right.
> That includes not holding any locks across any call that may block,
> which means you have to choose carefully which libwayland-client
> functions you call.
> Since it is possible that sending any request from the client may
> (rarely) cause implicit flushing on the connection, I suspect it is not
> safe to call any Wayland protocol API while holding locks shared with
> the compositor.
> Sharing any locks with the compositor would also be bad because the
> client could accidentally stall the whole compositor, but that is a
> caveat you have to decide for yourself.
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
More information about the wayland-devel