[Top][All Lists]

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

Re: Threads in emacs implementation

From: Nic Ferrier
Subject: Re: Threads in emacs implementation
Date: Wed, 08 Jun 2005 23:26:02 +0100

Magnus Henoch <address@hidden> writes:

> Nic Ferrier <address@hidden> writes:
>> We don't need threads in elisp. Just more asynchronous network
>> implementations.
> Good point.
> What is the best way to send a large amount of data to a network
> connection in the background?  You could send a chunk at a time with
> process-send-string and then recurse with run-with-idle-timer, but it
> seems that this will either block the UI or cause unnecessarily slow
> transfer unless the chunk size and the delay are right.

How about putting the data in a buffer and using: 


In respect of sending lots of data, the same problem applies when
using either threads or async. Consider the example of the text of the
play The Tempest to a network process.

The user can kill the buffer, alter the buffer, delete bits from the
buffer, all while the transfer is going on. So the only way to achieve
this is to lock the buffer first.

>> Anyway, async code is so much more fun to write than threaded
>> code. Threads are for beginners.
> Can you elaborate?  I don't see how
> (defun foo-1 ()
>   (send-request-with-callback 'foo-2))
> (defun foo-2 (response)
>   (do-something response))
> is more fun to write than:
> (defun foo ()
>   (let ((response (send-request-and-get-response)))
>     (do-something response)))

I was trying to be amusing. Asynchronous code is much harder to write
than threaded code, hence threaded code is for beginners.


reply via email to

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