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

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

Waiting for a condition


From: spamfilteraccount
Subject: Waiting for a condition
Date: 2 Jun 2006 04:00:29 -0700
User-agent: G2/0.2

I have a code where I'd like to perform an asynchronous operation and
then wait for the result of the operation synchronously in place. When
the operation is finished it calls a function, so I can do a signalling
there. If the operation was successful then the synchronous code should
continue, otherwise it should abort.

I came up with this solution which works, but inelegant imho:

  ...
  (let ((timeout 5))
    (while (and (not condition)
                (> timeout 0)
                (message (format "Waiting for condition... (%s)"
timeout))
                (sit-for 1))
      (decf timeout)))
  (unless condition
    (error "nope!")))
  ...

Is there a way to yield the execution here and wake it up when the
operation is finished (with timeout), without having to poll the
condition? I know sit-for returns is input is available. Should I
generate some kind of dummy event to wake sit-for up? But what event?
Mouse move?



reply via email to

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