From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: SAKURAI Masashi Newsgroups: gmane.emacs.devel Subject: Re: Concurrency, again Date: Sat, 15 Oct 2016 13:45:58 +0900 Message-ID: <201610150446.u9F4jwms021218@ms-omx61.plus.so-net.ne.jp> References: <87wq97i78i.fsf@earlgrey.lan> <86k2dk77w6.fsf@molnjunk.nocrew.org> <9D64B8EA-DB52-413D-AE6A-264416C391F3@iotcl.com> <83int1g0s5.fsf@gnu.org> <83twckekqq.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Trace: blaine.gmane.org 1476506788 6089 195.159.176.226 (15 Oct 2016 04:46:28 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 15 Oct 2016 04:46:28 +0000 (UTC) User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/24.5 Mule/6.0 (HANACHIRUSATO) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Oct 15 06:46:25 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 1bvGrV-0000fM-JO for ged-emacs-devel@m.gmane.org; Sat, 15 Oct 2016 06:46:21 +0200 Original-Received: from localhost ([::1]:50434 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bvGrT-0007mY-SR for ged-emacs-devel@m.gmane.org; Sat, 15 Oct 2016 00:46:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48969) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bvGrL-0007m0-Ii for emacs-devel@gnu.org; Sat, 15 Oct 2016 00:46:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bvGrI-0005Y6-Bw for emacs-devel@gnu.org; Sat, 15 Oct 2016 00:46:11 -0400 Original-Received: from ms-omx51.so-net.ne.jp ([202.238.84.151]:45250) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bvGrH-0005WK-TE for emacs-devel@gnu.org; Sat, 15 Oct 2016 00:46:08 -0400 Original-Received: from ms-omx61.so-net.ne.jp (ms-omx61.plus.so-net.ne.jp [10.240.84.163]) by ms-omx51.plus.so-net.ne.jp with ESMTP id u9F4k31Z023393 for ; Sat, 15 Oct 2016 13:46:03 +0900 Original-Received: from liza2.kiwanami.net (119-170-101-122.rev.home.ne.jp [119.170.101.122]) (authenticated) by ms-omx61.plus.so-net.ne.jp with ESMTP id u9F4jwms021218 (using TLSv1/SSLv3 with cipher AES128-SHA (128 bits)) for ; Sat, 15 Oct 2016 13:46:03 +0900 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 202.238.84.151 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:208272 Archived-At: At Wed, 12 Oct 2016 11:19:11 -0700, John Wiegley wrote: > : > What we're talking about here is not the kind of concurrency that leads to > nightmares involving corruption of global state, but cooperative concurrency. > Think of it as "timers, done right", if that helps. It would make a library > like emacs-deferred trivial to write, for example, which today is tortuously > implemented on top of the hackish timers we have now. emacs-deferred is built on tick-timer function (as browser's Promise implementations do), and provides async APIs not only to run async tasks but also to connect them without callback continuation. I have made many programs on it and built async RPC to use desired functions of other language environments from emacs. In my experience so far, emacs-deferred has worked well. (I know some issues on github, but now I have no time to revise it, such as lexbind and cl-lib.) Then, I have learned that race bug, dead-lock and not-reproducible bug are terrible even in the single-thread model, and I realized we should choose concurrent programming without shared mutable state or locking. So, I think multi-process model with IPC messaging is better for emacs, like browser's web-worker. I think they have helpful knowledge about retrofitted concurrency: why did they design the isolated thread with messaging, not simple thread API? -- SAKURAI, Masashi (family, given) m.sakurai@kiwanami.net