* multithreading in Elisp?
@ 2003-06-01 18:46 Florian von Savigny
2003-06-02 8:19 ` Kai Großjohann
0 siblings, 1 reply; 7+ messages in thread
From: Florian von Savigny @ 2003-06-01 18:46 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 690 bytes --]
>From what the belowmentioned Web pages seem to imply, it seems
impossible to have an elisp program do some sort of "multithreading"
whatsoever; I mean the simultaneous execution of tasks (writing
simultaneously in two different buffers, for instance).
Is that so? IOW, you /always/ have to wait for a function to finish?
http://per.bothner.com/papers/Freenix00/Freenix00.html
http://slashdot.org/articles/01/10/21/2329254.shtml
--
Florian v. Savigny
If you are going to reply in private, please be patient, as I only
check for mail something like once a week. - Si vous allez répondre
personellement, patientez s.v.p., car je ne lis les courriels
qu'environ une fois par semaine.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: multithreading in Elisp?
2003-06-01 18:46 multithreading in Elisp? Florian von Savigny
@ 2003-06-02 8:19 ` Kai Großjohann
2003-06-03 13:14 ` Florian von Savigny
0 siblings, 1 reply; 7+ messages in thread
From: Kai Großjohann @ 2003-06-02 8:19 UTC (permalink / raw)
Florian von Savigny <florian265@uboot.com> writes:
> From what the belowmentioned Web pages seem to imply, it seems
> impossible to have an elisp program do some sort of "multithreading"
> whatsoever; I mean the simultaneous execution of tasks (writing
> simultaneously in two different buffers, for instance).
You can do cooperative multitasking, MacOS-style, by using timers or
process filters or the like. (MacOS means before X.)
--
This line is not blank.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: multithreading in Elisp?
2003-06-02 8:19 ` Kai Großjohann
@ 2003-06-03 13:14 ` Florian von Savigny
2003-06-03 13:19 ` David Kastrup
2003-06-06 12:10 ` Kai Großjohann
0 siblings, 2 replies; 7+ messages in thread
From: Florian von Savigny @ 2003-06-03 13:14 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1093 bytes --]
kai.grossjohann@gmx.net (Kai Großjohann) writes:
> You can do cooperative multitasking, MacOS-style, by using timers or
> process filters or the like. (MacOS means before X.)
Do you have an (arbitrary) code example at hand? My imagination does
not reach far enough to implement commands that run in parallel by
means of a process filter (maybe you mean "outsourcing" the task that
is to run in the background with start-process?). I have no idea, on
the other hand, what a timer is (it doesn't have to do with the diary,
does it ... ?).
I would not really care whether the multitasking is preemptive or
cooperative, as long as the possibility is there at all. What I would
like to achieve is to have emacs retrieve some text from an external
program and write it in a different buffer, while it still allows the
user to edit his text.
Florian v. Savigny
If you are going to reply in private, please be patient, as I only
check for mail something like once a week. - Si vous allez répondre
personellement, patientez s.v.p., car je ne lis les courriels
qu'environ une fois par semaine.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: multithreading in Elisp?
2003-06-03 13:14 ` Florian von Savigny
@ 2003-06-03 13:19 ` David Kastrup
2003-06-06 12:10 ` Kai Großjohann
1 sibling, 0 replies; 7+ messages in thread
From: David Kastrup @ 2003-06-03 13:19 UTC (permalink / raw)
Florian von Savigny <florian265@uboot.com> writes:
> kai.grossjohann@gmx.net (Kai Großjohann) writes:
>
> > You can do cooperative multitasking, MacOS-style, by using timers or
> > process filters or the like. (MacOS means before X.)
>
> Do you have an (arbitrary) code example at hand? My imagination does
> not reach far enough to implement commands that run in parallel by
> means of a process filter (maybe you mean "outsourcing" the task that
> is to run in the background with start-process?). I have no idea, on
> the other hand, what a timer is (it doesn't have to do with the diary,
> does it ... ?).
>
> I would not really care whether the multitasking is preemptive or
> cooperative, as long as the possibility is there at all. What I would
> like to achieve is to have emacs retrieve some text from an external
> program and write it in a different buffer, while it still allows the
> user to edit his text.
Look up comint-mode in the Elisp manual.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: multithreading in Elisp?
2003-06-03 13:14 ` Florian von Savigny
2003-06-03 13:19 ` David Kastrup
@ 2003-06-06 12:10 ` Kai Großjohann
2003-06-06 23:52 ` Michael M Mason
1 sibling, 1 reply; 7+ messages in thread
From: Kai Großjohann @ 2003-06-06 12:10 UTC (permalink / raw)
Florian von Savigny <florian265@uboot.com> writes:
> kai.grossjohann@gmx.net (Kai Großjohann) writes:
>
>> You can do cooperative multitasking, MacOS-style, by using timers or
>> process filters or the like. (MacOS means before X.)
>
> Do you have an (arbitrary) code example at hand? My imagination does
> not reach far enough to implement commands that run in parallel by
> means of a process filter (maybe you mean "outsourcing" the task that
> is to run in the background with start-process?). I have no idea, on
> the other hand, what a timer is (it doesn't have to do with the diary,
> does it ... ?).
I think it's not necessary to use a lot of imagination.
Timers are part of Emacs. For example, the following is good for
Brits:
(defun tea-time ()
(message "It's time for tea!"))
(run-at-time "5:00pm" nil 'tea-time)
In addition to run-at-time, also see run-with-timer and
run-with-idle-timer. Also note that run-at-time allows you to run
the function repeatedly, every second, say.
Process filters are indeed used when you want to communicate with a
process. When the process creates some output, your process filter
function will be called with a string arg, the arg contains the
output from the process. You can then do whatever you like and return.
> I would not really care whether the multitasking is preemptive or
> cooperative, as long as the possibility is there at all. What I would
> like to achieve is to have emacs retrieve some text from an external
> program and write it in a different buffer, while it still allows the
> user to edit his text.
This is really easy: you can start a process with start-process.
Then, from time to time, you can call accept-process-output to read
output from that process, or you can use a process filter which just
appends the output to the end of the buffer.
Or you run the process via comint, as has been suggested before in
this thread. I think that's not a bad solution; it's a fairly
high-level facility.
--
This line is not blank.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: multithreading in Elisp?
2003-06-06 12:10 ` Kai Großjohann
@ 2003-06-06 23:52 ` Michael M Mason
2003-06-07 10:53 ` tea (was: multithreading in Elisp?) lawrence mitchell
0 siblings, 1 reply; 7+ messages in thread
From: Michael M Mason @ 2003-06-06 23:52 UTC (permalink / raw)
On Fri, 06 Jun 2003 14:10:10 +0200, kai.grossjohann@gmx.net (Kai
Großjohann) wrote:
>Timers are part of Emacs. For example, the following is good for
>Brits:
>
>(defun tea-time ()
> (message "It's time for tea!"))
>(run-at-time "5:00pm" nil 'tea-time)
Being a Brit, I couldn't help noticing the rather serious bug in the
above code snippet. I hope you won't mind me offering an improved
version:-
(defun tea-time ()
(message "It's time for tea!"))
(run-at-time "9:30am" nil 'tea-time)
(run-at-time "10:00am" nil 'tea-time)
(run-at-time "11:00am" nil 'tea-time)
(run-at-time "11:30am" nil 'tea-time)
(run-at-time "12:00am" nil 'tea-time)
(run-at-time "1:00pm" nil 'tea-time)
(run-at-time "2:00pm" nil 'tea-time)
(run-at-time "3:00pm" nil 'tea-time)
(run-at-time "3:30pm" nil 'tea-time)
(run-at-time "4:00pm" nil 'tea-time)
(run-at-time "5:00pm" nil 'tea-time)
--
Michael
^ permalink raw reply [flat|nested] 7+ messages in thread
* tea (was: multithreading in Elisp?)
2003-06-06 23:52 ` Michael M Mason
@ 2003-06-07 10:53 ` lawrence mitchell
0 siblings, 0 replies; 7+ messages in thread
From: lawrence mitchell @ 2003-06-07 10:53 UTC (permalink / raw)
Michael M Mason wrote:
[...]
> Being a Brit, I couldn't help noticing the rather serious bug in the
> above code snippet. I hope you won't mind me offering an improved
> version:-
This one looks more reasonable, I notice you slow down in the
afternoon though. Is this a bug?
> (defun tea-time ()
> (message "It's time for tea!"))
> (run-at-time "9:30am" nil 'tea-time)
> (run-at-time "10:00am" nil 'tea-time)
> (run-at-time "11:00am" nil 'tea-time)
> (run-at-time "11:30am" nil 'tea-time)
> (run-at-time "12:00am" nil 'tea-time)
> (run-at-time "1:00pm" nil 'tea-time)
> (run-at-time "2:00pm" nil 'tea-time)
> (run-at-time "3:00pm" nil 'tea-time)
> (run-at-time "3:30pm" nil 'tea-time)
> (run-at-time "4:00pm" nil 'tea-time)
> (run-at-time "5:00pm" nil 'tea-time)
This of course, may be simplified to
(run-at-time "9:30am" (* 30 60) 'tea-time)
You missed one:
(defun close-of-play (&optional reason)
(call-stumps)
(run-hooks 'close-of-play-hooks)
(and reason (message "%s stopped play." reason)))
(if rain-stopped-play
(close-of-play "Rain")
(run-at-time "6:00pm" nil 'close-of-play))
HTH
--
lawrence mitchell <wence@gmx.li>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2003-06-07 10:53 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-06-01 18:46 multithreading in Elisp? Florian von Savigny
2003-06-02 8:19 ` Kai Großjohann
2003-06-03 13:14 ` Florian von Savigny
2003-06-03 13:19 ` David Kastrup
2003-06-06 12:10 ` Kai Großjohann
2003-06-06 23:52 ` Michael M Mason
2003-06-07 10:53 ` tea (was: multithreading in Elisp?) lawrence mitchell
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.