[Top][All Lists]

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

other "concurrency" approaches

From: Nic Ferrier
Subject: other "concurrency" approaches
Date: Tue, 03 Nov 2015 11:50:37 +0000

While you are all talking about the concurrency branch I thought I'd
drop a line about other approaches that may be more tactical but would
be beneficial.

Some work has done by JohnW, others and myself on concurrency through
processes and the use of the existing process interface.

It's quite difficult to do this, but very beneficial. In effect what
we've been trying to do is emulate a fork model by just starting emacs
as a separate process. The fork approach to multiprocessing, while being
the tried and tested and perhaps rather old fashioned approach, has also
been very successful in modern languages like Python

In Emacs this is difficult because we don't have fork. And we don't have
a straight forward way of starting an Emacs process without a gui. You
can start a daemon, but daemons aren't what you want. In addition the
protocol for talking to daemons over sockets isn't that easy either.

Fork looks very hard to solve, in the same way that threads are quite
hard to solve.

But starting a headless Emacs, given that we have daemon already,
wouldn't be that hard.

What you want is the ability to do something like this:

 (let ((proc (start-process "emacs" args-to-make-it-headless)))
   (process-send-string proc (prin1-to-string '(+ 1 (* 30 45))))
   (process-send-eof proc)
   (print (buffer-string (process-buffer proc))))

in other words, an Emacs that just reads forms from stdin and executes
them and outputs to stdout.

The only complex thing here is how Emacs would understand that a form
has ended. I considered here just using end of line as the terminator
and if the form couldn't be read just issuing a read error. Other more
complex readers with a better line oriented UI might come later... but
for the use case of starting an Emacs from Emacs and communicating with
it it wouldn't be necessary.

Doing just this relatively small change would make an enormous
difference to building concurrency stuff in Emacs.


reply via email to

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