* Nicer way to wake sit-for up?
@ 2006-06-08 10:31 spamfilteraccount
2006-06-08 11:28 ` Johan Bockgård
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: spamfilteraccount @ 2006-06-08 10:31 UTC (permalink / raw)
I have a code where the command loop executes a command which is
waiting for arriving data with sit-for. When the data arrives from the
network a callback is invoked and I wake sit-for up with a dummy event
like this:
the callback:
...
(setq unread-command-events (cons 'data-arrived
unread-command-events))
...
the command:
...
(sit-for 5)
(if (eq (car unread-command-events) 'data-arrived)
(setq unread-command-events (cdr unread-command-events)))
...
It works, but feels a bit clumsy. Is it a simpler or nicer way to do
this?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Nicer way to wake sit-for up?
2006-06-08 10:31 Nicer way to wake sit-for up? spamfilteraccount
@ 2006-06-08 11:28 ` Johan Bockgård
2006-06-08 12:53 ` Kim F. Storm
[not found] ` <mailman.2764.1149780214.9609.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 5+ messages in thread
From: Johan Bockgård @ 2006-06-08 11:28 UTC (permalink / raw)
spamfilteraccount@gmail.com writes:
> I have a code where the command loop executes a command which is
> waiting for arriving data with sit-for. When the data arrives from
> the network a callback is invoked and I wake sit-for up with a dummy
> event like this:
[...]
> It works, but feels a bit clumsy. Is it a simpler or nicer way to do
> this?
`accept-process-output'
--
Johan Bockgård
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Nicer way to wake sit-for up?
2006-06-08 10:31 Nicer way to wake sit-for up? spamfilteraccount
2006-06-08 11:28 ` Johan Bockgård
@ 2006-06-08 12:53 ` Kim F. Storm
[not found] ` <mailman.2764.1149780214.9609.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 5+ messages in thread
From: Kim F. Storm @ 2006-06-08 12:53 UTC (permalink / raw)
spamfilteraccount@gmail.com writes:
> I have a code where the command loop executes a command which is
> waiting for arriving data with sit-for. When the data arrives from the
> network a callback is invoked and I wake sit-for up with a dummy event
> like this:
>
> the callback:
>
> ...
> (setq unread-command-events (cons 'data-arrived
> unread-command-events))
> ...
>
I can't think of a better way here, but you can just write
(push 'data-arrived unread-command-events)
>
> ...
> (sit-for 5)
> (if (eq (car unread-command-events) 'data-arrived)
> (setq unread-command-events (cdr unread-command-events)))
> ...
You could arrange for the data-arrived event to be ignored, e.g.
(define-key global-map [data-arrived] 'ignore)
Perhaps, you could use ignore instead of data-arrived, i.e.
(define-key global-map [ignore] 'ignore)
and
(push 'ignore unread-command-events)
--
Kim F. Storm http://www.cua.dk
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Nicer way to wake sit-for up?
[not found] ` <mailman.2764.1149780214.9609.help-gnu-emacs@gnu.org>
@ 2006-06-08 15:34 ` David Kastrup
2006-06-09 8:40 ` spamfilteraccount
0 siblings, 1 reply; 5+ messages in thread
From: David Kastrup @ 2006-06-08 15:34 UTC (permalink / raw)
no-spam@cua.dk (Kim F. Storm) writes:
> spamfilteraccount@gmail.com writes:
>
>> I have a code where the command loop executes a command which is
>> waiting for arriving data with sit-for. When the data arrives from the
>> network a callback is invoked and I wake sit-for up with a dummy event
>> like this:
>>
>> the callback:
>>
>> ...
>> (setq unread-command-events (cons 'data-arrived
>> unread-command-events))
>> ...
>>
>
> I can't think of a better way here, but you can just write
>
> (push 'data-arrived unread-command-events)
>>
>> ...
>> (sit-for 5)
>> (if (eq (car unread-command-events) 'data-arrived)
>> (setq unread-command-events (cdr unread-command-events)))
>> ...
>
> You could arrange for the data-arrived event to be ignored, e.g.
>
> (define-key global-map [data-arrived] 'ignore)
>
>
>
> Perhaps, you could use ignore instead of data-arrived, i.e.
>
> (define-key global-map [ignore] 'ignore)
>
> and
>
> (push 'ignore unread-command-events)
Maybe (push 'mouse-movement unread-command-events) would do the trick?
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Nicer way to wake sit-for up?
2006-06-08 15:34 ` David Kastrup
@ 2006-06-09 8:40 ` spamfilteraccount
0 siblings, 0 replies; 5+ messages in thread
From: spamfilteraccount @ 2006-06-09 8:40 UTC (permalink / raw)
Thanks for the ideas.
I'm a little surprised there is no built-in function to do that. It's a
pretty essential operation when having to work with asynchronous
requests.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-06-09 8:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-08 10:31 Nicer way to wake sit-for up? spamfilteraccount
2006-06-08 11:28 ` Johan Bockgård
2006-06-08 12:53 ` Kim F. Storm
[not found] ` <mailman.2764.1149780214.9609.help-gnu-emacs@gnu.org>
2006-06-08 15:34 ` David Kastrup
2006-06-09 8:40 ` spamfilteraccount
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).