From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: non-blocking sockets (was Re: Are there plans for a multi-threaded Emacs?) Date: 05 Dec 2003 12:35:01 +0100 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: References: <87oevbes4h.fsf@emacswiki.org> <20031117040607.C6C5D79B72@server2.messagingengine.com> <87ekvpx18d.fsf@emptyhost.emptydomain.de> <4nad6cikxy.fsf@holmes.bwh.harvard.edu> <4nllpt3hr3.fsf@lockgroove.bwh.harvard.edu> <5bad69zd43.fsf@lister.roxen.com> <4noeuon378.fsf@lockgroove.bwh.harvard.edu> <87ptf4zib0.fsf@kanga.tapsellferrier.co.uk> <87k75czh0b.fsf_-_@kanga.tapsellferrier.co.uk> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1070620811 20153 80.91.224.253 (5 Dec 2003 10:40:11 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 5 Dec 2003 10:40:11 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Fri Dec 05 11:40:08 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1ASDNY-0001sT-00 for ; Fri, 05 Dec 2003 11:40:08 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1ASDNY-0000sz-00 for ; Fri, 05 Dec 2003 11:40:08 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1ASEJu-0007ND-U4 for emacs-devel@quimby.gnus.org; Fri, 05 Dec 2003 06:40:26 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1ASEHG-00074G-I8 for emacs-devel@gnu.org; Fri, 05 Dec 2003 06:37:42 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1ASEGj-00070V-7c for emacs-devel@gnu.org; Fri, 05 Dec 2003 06:37:40 -0500 Original-Received: from [212.88.64.25] (helo=mail-relay.sonofon.dk) by monty-python.gnu.org with smtp (Exim 4.24) id 1ASEGh-0006yy-LV for emacs-devel@gnu.org; Fri, 05 Dec 2003 06:37:07 -0500 Original-Received: (qmail 74615 invoked from network); 5 Dec 2003 10:35:40 -0000 Original-Received: from unknown (HELO kfs-l.imdomain.dk.cua.dk) (213.83.150.2) by 0 with SMTP; 5 Dec 2003 10:35:40 -0000 Original-To: Nic Ferrier In-Reply-To: <87k75czh0b.fsf_-_@kanga.tapsellferrier.co.uk> Original-Lines: 56 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:18408 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:18408 Nic Ferrier writes: > Nic Ferrier writes: > > > Hmmm... maybe if most of the threading issues are with socket > > communication then better sentinels would be a good idea. Maybe a > > callback API for setting up and reading/writing to sockets would > > really useful. Such an API would be a doddle to write of course. > > Doh! > > Elisp 21 already has non-blocking sockets... I don't remember them > from the last time I did any socket stuff but they are there. Yes I know (I added it :-). Problem is that often people whine about the things that are missing, rather than trying to use the things that are already there. > > So one big win would be to convert as much network reliant code to > using non-blocking sockets which someone already said. > Indeed! Sending and receiving mail could definitely run "in the background" using non-blocking i/o. > > Since 'open-network-stream-nowait' returns nil when it's not > supported it seems fairly safe to add it to all networking > code. Maybe a new form is needed: > > open-network-stream-nowait-if-possible > > which does an nbio connection if it can but otherwise a normal one. > I considered this when I created the interface (the low-level function is make-network-process), but I found that there is no general way in which you could use either nbio or bio with the same sentinels and filters, as the sequence of events is different. IMO it is better not to make an open-network-stream-nowait-if-possible which pretends it is simpler than it really is! Using nbio _is_ a little more tricky that blocking io. > > If your system doesn't support nbio then you'll still have to wait > for Emacs threads for faster network connections /8-> > Personally, I wouldn't care about such systems. -- Kim F. Storm http://www.cua.dk