help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Asynchronously downloading a file


From: Daniel Pittman
Subject: Re: Asynchronously downloading a file
Date: Fri, 02 Jul 2010 19:06:23 +1000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Qiang Guo <address@hidden> writes:

> Emacs adheres to single thread fervently, so it may be impossible to do this
> within emacs.

That isn't actually all that true: while there is only a single thread of
execution within Emacs you can address this in one of two ways:

The obvious, and sane, way is to take advantage of the event-driven I/O
functionality present in Emacs as part of the process / network-connection
filter infrastructure.

In this mode you tell the system to start the download, then your function is
called (or data collected in a buffer) as it is available to be read.  While
there is only a single thread, this will jump over to handling your download
transparently to doing other activities.


The second way is to use an external process to do the same; you can even
invoke 'emacs --batch --eval' if you really want to. :)

        Daniel

The second way is kind of wasteful given that `open-network-stream' is
actually entirely asynchronous and all.
-- 
✣ Daniel Pittman            ✉ address@hidden            ☎ +61 401 155 707
               ♽ made with 100 percent post-consumer electrons




reply via email to

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