From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Davis Herring" Newsgroups: gmane.emacs.devel Subject: Re: Async DNS lookups Date: Thu, 4 Nov 2010 13:40:27 -0700 (PDT) Message-ID: <49950.130.55.118.19.1288903227.squirrel@webmail.lanl.gov> References: <35456.130.55.118.19.1288819785.squirrel@webmail.lanl.gov> Reply-To: herring@lanl.gov NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1288903245 32075 80.91.229.12 (4 Nov 2010 20:40:45 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 4 Nov 2010 20:40:45 +0000 (UTC) Cc: Andreas Schwab , emacs-devel@gnu.org To: "Stefan Monnier" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 04 21:40:40 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 1PE6bv-0007mF-JN for ged-emacs-devel@m.gmane.org; Thu, 04 Nov 2010 21:40:39 +0100 Original-Received: from localhost ([127.0.0.1]:56239 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PE6bv-0006Ll-1Y for ged-emacs-devel@m.gmane.org; Thu, 04 Nov 2010 16:40:39 -0400 Original-Received: from [140.186.70.92] (port=46130 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PE6bo-0006Kd-33 for emacs-devel@gnu.org; Thu, 04 Nov 2010 16:40:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PE6bm-0000g8-Gi for emacs-devel@gnu.org; Thu, 04 Nov 2010 16:40:31 -0400 Original-Received: from proofpoint1.lanl.gov ([204.121.3.25]:42202) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PE6bm-0000g1-3Y for emacs-devel@gnu.org; Thu, 04 Nov 2010 16:40:30 -0400 Original-Received: from mailrelay1.lanl.gov (mailrelay1.lanl.gov [128.165.4.101]) by proofpoint1 (8.14.3/8.14.3) with ESMTP id oA4KeRGj026221; Thu, 4 Nov 2010 14:40:27 -0600 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by mailrelay1.lanl.gov (Postfix) with ESMTP id CEFA0150941; Thu, 4 Nov 2010 14:40:27 -0600 (MDT) X-NIE-2-Virus-Scanner: amavisd-new at mailrelay1.lanl.gov Original-Received: from webmail1.lanl.gov (webmail1.lanl.gov [128.165.4.106]) by mailrelay1.lanl.gov (Postfix) with ESMTP id B6AA91509AF; Thu, 4 Nov 2010 14:40:27 -0600 (MDT) Original-Received: by webmail1.lanl.gov (Postfix, from userid 48) id B4A3F1CA839D; Thu, 4 Nov 2010 14:40:27 -0600 (MDT) Original-Received: from 130.55.118.19 (SquirrelMail authenticated user 196434) by webmail.lanl.gov with HTTP; Thu, 4 Nov 2010 13:40:27 -0700 (PDT) In-Reply-To: User-Agent: SquirrelMail/1.4.8-5.el5_4.10.lanl3 X-Priority: 3 (Normal) Importance: Normal X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.2.15, 1.0.148, 0.0.0000 definitions=2010-11-04_10:2010-11-04, 2010-11-04, 1970-01-01 signatures=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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:132375 Archived-At: > lock(pending_funcalls); > setcar(result, pending_funcalls); > pending_funcalls = result; > unlock(pending_funcalls); [snip] > I.e. you'll probably want to use some new variable, very similar to > pending_funcalls, but for "pending_c_funcalls" so that the pending calls > can first do some C preprocessing to turn the C result data into Lisp data > and then call the Elisp callback. And then you don't want to lock the pending_funcalls variable after all: you want to have a lock on the pending_c_funcalls and do something like /* DNS thread */ x->data=lookup(...); /* slow */ lock(pending_c_funcalls_mutex); x->next=pending_c_funcalls; pending_c_funcalls=x; unlock(pending_c_funcalls_mutex); /* main thread */ lock(pending_c_funcalls_mutex); for(;pending_c_funcalls;pending_c_funcalls=pending_c_funcalls->next) pending_funcalls=Fcons(convert_async(pending_c_funcalls), pending_funcalls); unlock(pending_c_funcalls_mutex); /* ...existing Ffuncall() code... */ Right? Davis -- This product is sold by volume, not by mass. If it appears too dense or too sparse, it is because mass-energy conversion has occurred during shipping.