emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Async DNS lookups


From: Davis Herring
Subject: Re: Async DNS lookups
Date: Thu, 4 Nov 2010 13:40:27 -0700 (PDT)
User-agent: SquirrelMail/1.4.8-5.el5_4.10.lanl3

>    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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]