Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip deferred:wait-idle delay while waiting for previously deferred task to complete? #55

Open
sten0 opened this issue Aug 3, 2019 · 0 comments

Comments

@sten0
Copy link

sten0 commented Aug 3, 2019

Hi,

I'm working on making a CPU-intensive function called from the modeline loop asynchronous, and am using a simple boolean var as a lock to skip body of a deferred:nextc it function when the lock is active. Unfortunately deferred:wait-idle unconditionally blocks execution of the deferred task chain. Would it be possible useful to add a third argument to its function definition? Something like a bool, that if nil will not block while waiting for the idle timer to expire (eg: skip the timer if nil). The form would become deferred:wait-idle (msec) (optional-boolean-lock).

I'm using a simple:

(deferred:$
  (deferred:wait-idle idle-wait-value)
  (deferred:next it (lambda (elapsed) set-lock-and-do-slow-CPU-intensive-stuff))
  (deferred:next it (lambda (result) format-result-as-a-string-and-set-a-var-and-unset-lock)))

The buffer-local var set in the 3rd task is evaluated in the modeline loop. The 3rd task also unsets the lock. The specific issue I'm experiencing is that the unconditional wait-idle introduces a minimum latency of 2x the idle-wait-value. In my case it might be possible to merge 2nd and 3rd tasks, but I believe other people would find it useful to be able to conditionally skip the wait-idle task, thus eliminating the guarantied latency of 1x idle-wait-value.

Thank you for maintaining emacs-deferred!
Nicholas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant