From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tom Tromey Newsgroups: gmane.emacs.devel Subject: Re: Async DNS lookups Date: Tue, 02 Nov 2010 12:30:16 -0600 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1288722388 3486 80.91.229.12 (2 Nov 2010 18:26:28 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 2 Nov 2010 18:26:28 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Nov 02 19:26:24 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PDLYq-00031s-87 for ged-emacs-devel@m.gmane.org; Tue, 02 Nov 2010 19:26:20 +0100 Original-Received: from localhost ([127.0.0.1]:42603 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PDLYp-0003M4-Ej for ged-emacs-devel@m.gmane.org; Tue, 02 Nov 2010 14:26:19 -0400 Original-Received: from [140.186.70.92] (port=34429 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PDLYg-0003KV-Af for emacs-devel@gnu.org; Tue, 02 Nov 2010 14:26:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PDLYb-000118-V3 for emacs-devel@gnu.org; Tue, 02 Nov 2010 14:26:10 -0400 Original-Received: from mx1.redhat.com ([209.132.183.28]:31910) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PDLYb-00010x-Nv for emacs-devel@gnu.org; Tue, 02 Nov 2010 14:26:05 -0400 Original-Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oA2IQ3R7023885 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 2 Nov 2010 14:26:03 -0400 Original-Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oA2IQ3AE009547 for ; Tue, 2 Nov 2010 14:26:03 -0400 Original-Received: from parfait.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id oA2IQ1IF029592 for ; Tue, 2 Nov 2010 14:26:02 -0400 In-Reply-To: (Lars Magne Ingebrigtsen's message of "Tue, 02 Nov 2010 19:13:30 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:132291 Archived-At: >>>>> "Lars" == Lars Magne Ingebrigtsen writes: Lars> 2) C does pthread_create() (right?), and lets the main thread return Lars> from the call. The other thread just does a normal getaddrinfo(). Lars> 3) When getaddrinfo() returns, we do Lars> (funcall #'my-callback result my-data) Lars> But 3) probably needs to be in the same sort of state that timers run Lars> in, so that we don't have two Emacs Lisp threads running at the same Lars> time. Any pointers where to look for how to "halt" the main Emacs Lars> thread? Or something? I would suggest just keeping all the thread stuff in C. Don't provide any callback. Instead, have the main thread run the event loop (a la sit-for -- I don't know the C functions offhand) and return an answer when the worker thread reports back. You especially want to avoid referencing any lisp stuff from the worker thread. If you do that then you will need to make the GC thread-aware. This is doable (it is on the concurrency branch), but it is overkill for this application. Tom