emacs-devel
[Top][All Lists]
Advanced

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

Re: Can we go GTK-only?


From: Eli Zaretskii
Subject: Re: Can we go GTK-only?
Date: Wed, 02 Nov 2016 17:46:26 +0200

> Date: Wed, 02 Nov 2016 14:00:49 +0900
> From: YAMAMOTO Mitsuharu <address@hidden>
> Cc: Daniel Colascione <address@hidden>,
>       address@hidden,
>       address@hidden,
>       address@hidden,
>       address@hidden
> 
> > The only platform I know about that starts non-main threads which
> > run Emacs application code is MS-Windows, and there we don't
> > allocate anything off the heap, at least not off the same heap that
> > is used by the main (Lisp) thread.
> 
> The font backend driver macfont.m imported from the Mac port does
> deallocation off the main thread for some data that were allocated in
> the main thread.
> 
>   1489                      dispatch_group_async (group, queue, ^{
>   1490                          int nkeys;
>   1491                          uintptr_t key;
>   1492                          nkeys = nkeys_or_perm;
>   1493                          for (key = row * (256 / NGLYPHS_IN_VALUE); ; 
> key++)
>   1494                            if (CFDictionaryContainsKey (dictionary,
>   1495                                                         (const void *) 
> key))
>   1496                              {
>   1497                                CFDictionaryRemoveValue (dictionary,
>   1498                                                         (const void *) 
> key);
>   1499                                if (--nkeys == 0)
>   1500                                  break;
>   1501                              }
>   1502                        });
> 
> I can disable this for NS if it does not fit with the current policy
> of GNU Emacs mainline source code.

I know next to nothing about NS.  These are system APIs, right?  If
so, calling them could be okay, and I defer to NS and OS X people here
to make that call.

One things bothers me, though: can't this arrangement, where data is
allocated in one thread and deallocated in another, cause races?  Or
do these threads have means to synchronize between them?

> (You can find more use cases of threads via libdispatch in the Mac
> port.  Even basic drawings are done off the main thread.)

That's okay, the non-main threads in the MS-Windows build also do some
non-trivial stuff.  As long as there's no QUIT, directly or
indirectly, in those other threads, and no calls that can cons Lisp
objects or cause GC etc., threads are safe.

> Of course, external libraries would do memory allocation/deallocation
> across the threads behind the scenes.

Sure, that's not what bothers me.

Thanks.



reply via email to

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