From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Can we go GTK-only? Date: Wed, 02 Nov 2016 17:46:26 +0200 Message-ID: <83mvhhnaul.fsf@gnu.org> References: <24db2975-17ca-ad01-20c8-df12071fa89a@dancol.org> <4615E73A-19E2-4B79-9889-D3FA686DDDE6@raeburn.org> <83bmy0pl8p.fsf@gnu.org> <831sywp7ew.fsf@gnu.org> <83y413nsjm.fsf@gnu.org> <83funbnngl.fsf@gnu.org> <83d1ifnmto.fsf@gnu.org> <20161101152027.5e94b6cc@jabberwock.cb.piermont.com> <83ziljm0ei.fsf@gnu.org> <7875855e-b632-491c-c616-4f3662a525af@dancol.org> <83vaw7lyoc.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1478101668 3188 195.159.176.226 (2 Nov 2016 15:47:48 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 2 Nov 2016 15:47:48 +0000 (UTC) Cc: perry@piermont.com, dancol@dancol.org, raeburn@raeburn.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: YAMAMOTO Mitsuharu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Nov 02 16:47:43 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c1xlB-0007Q6-Bh for ged-emacs-devel@m.gmane.org; Wed, 02 Nov 2016 16:47:29 +0100 Original-Received: from localhost ([::1]:55908 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1xlE-0000tu-2F for ged-emacs-devel@m.gmane.org; Wed, 02 Nov 2016 11:47:32 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44894) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1xk1-0000nr-44 for emacs-devel@gnu.org; Wed, 02 Nov 2016 11:46:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1xk0-0005cn-AP for emacs-devel@gnu.org; Wed, 02 Nov 2016 11:46:17 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:34500) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1xju-0005at-EW; Wed, 02 Nov 2016 11:46:10 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4901 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1c1xjt-0006X3-Dx; Wed, 02 Nov 2016 11:46:09 -0400 In-reply-to: (message from YAMAMOTO Mitsuharu on Wed, 02 Nov 2016 14:00:49 +0900) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:209114 Archived-At: > Date: Wed, 02 Nov 2016 14:00:49 +0900 > From: YAMAMOTO Mitsuharu > Cc: Daniel Colascione , > raeburn@raeburn.org, > emacs-devel@gnu.org, > monnier@iro.umontreal.ca, > perry@piermont.com > > > 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.