[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freedesktop-xorg
Subject:    Re: XInitThreads multiple times
From:       Aaron Plattner <aplattner () nvidia ! com>
Date:       2021-08-11 6:25:50
Message-ID: d9cec0cb-6c16-1f16-e735-f587668ef779 () nvidia ! com
[Download RAW message or body]

On 8/5/21 8:36 AM, Keith Packard wrote:
> Dawid Kowalczyk <niexx13@gmail.com> writes:
> 
>> Hello,
>>
>> Is it possible to call |XInitThreads| multiple times, for example 20
>> times and not worry who calls it first?
> 
> XInitThreads isn't re-entrant, so you need to ensure that it isn't
> getting invoked by multiple threads in parallel, but it does check to
> see if it has been called before, so it is safe to call multiple times
> in sequence.

Right, it's not thread-safe. From the man page:

DESCRIPTION
        The XInitThreads function initializes Xlib  support
        for  concurrent threads.  This function must be the
        first Xlib function a multi-threaded program calls,
        and **it must complete before any other Xlib call is
        made**.

(emphasis mine). Looking at the code, it looks like that rule includes 
other calls to XInitThreads and not just *other* Xlib functions.

-- Aaron
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic