[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/cape c1f7fa746b 104/146: Improve synchronization
From: |
ELPA Syncer |
Subject: |
[elpa] externals/cape c1f7fa746b 104/146: Improve synchronization |
Date: |
Sun, 9 Jan 2022 20:57:46 -0500 (EST) |
branch: externals/cape
commit c1f7fa746bc4d09ab10cede478e22a8a7c13c4f7
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Improve synchronization
---
cape.el | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/cape.el b/cape.el
index 01e19a651e..4a3a85944d 100644
--- a/cape.el
+++ b/cape.el
@@ -42,14 +42,10 @@
"Dictionary word list file."
:type 'string)
-(defcustom cape-company-async-timeout 1.0
+(defcustom cape-company-timeout 5.0
"Company asynchronous timeout."
:type 'float)
-(defcustom cape-company-async-wait 0.02
- "Company asynchronous busy waiting time."
- :type 'float)
-
(defcustom cape-dabbrev-min-length 4
"Minimum length of dabbrev expansions."
:type 'integer)
@@ -738,19 +734,26 @@ If INTERACTIVE is nil the function acts like a capf."
(defun cape--company-call (backend &rest args)
"Call Company BACKEND with ARGS."
;; Company backends are non-interruptible.
- (let ((old-toi throw-on-input)
+ (let ((toi throw-on-input)
(throw-on-input nil))
(pcase (apply backend args)
(`(:async . ,future)
(let ((res 'cape--waiting)
(start (time-to-seconds)))
- (funcall future (lambda (arg) (setq res arg)))
- ;; Force synchronization. The synchronization is interruptible!
- (let ((throw-on-input old-toi))
- (while (eq res 'cape--waiting)
- (sleep-for cape-company-async-wait)
- (when (> (- (time-to-seconds) start) cape-company-async-timeout)
- (error "Cape company backend async timeout"))))
+ (funcall future (lambda (arg)
+ (when (eq res 'cape--waiting)
+ (push 'cape--event unread-command-events))
+ (setq res arg)))
+ ;; Force synchronization.
+ (while (eq res 'cape--waiting)
+ ;; When we've got input, interrupt the computation.
+ (when (and unread-command-events toi)
+ (throw toi nil))
+ (when (> (- (time-to-seconds) start) cape-company-timeout)
+ (error "Cape company backend async timeout"))
+ (sit-for 0.1 'noredisplay))
+ ;; Remove cape--events introduced by future callback
+ (setq unread-command-events (delq 'cape--event unread-command-events))
res))
(res res))))
- [elpa] externals/cape 26401bfa6a 069/146: Unify cape-abbrev and cape-abbrev-capf, (continued)
- [elpa] externals/cape 26401bfa6a 069/146: Unify cape-abbrev and cape-abbrev-capf, ELPA Syncer, 2022/01/09
- [elpa] externals/cape d265a03e7f 074/146: cape-dabbrev: Make interactive, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 3eb7efc2d4 050/146: README: Expand reasoning, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 8cf2942881 085/146: Add comments regarding interruptible completion tables, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 488cfd9ed7 086/146: Move code around, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 2008d809b6 088/146: Add cape-capf-with-predicate, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 4b424150ef 090/146: cape-super-capf: Delete duplicates (Fix #13), ELPA Syncer, 2022/01/09
- [elpa] externals/cape da32e232d6 093/146: cape--company-call: Cheaper timeout checking, throw error, ELPA Syncer, 2022/01/09
- [elpa] externals/cape c4d821d55b 079/146: Add cape--symbol-annotation, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 2ce63259d7 097/146: Update README - Asynchronous Company backends work as expected, ELPA Syncer, 2022/01/09
- [elpa] externals/cape c1f7fa746b 104/146: Improve synchronization,
ELPA Syncer <=
- [elpa] externals/cape 1d69a06890 117/146: cape-tex/cape-sgml: Add autoloads, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 7f11b354df 124/146: cape-company-capf: Remove symbol restriction, ELPA Syncer, 2022/01/09
- [elpa] externals/cape a6db83b1bd 135/146: Improve repair function, ELPA Syncer, 2022/01/09
- [elpa] externals/cape f26e835929 131/146: README: Do not use hashed symbol, ELPA Syncer, 2022/01/09
- [elpa] externals/cape e23226cb1c 022/146: cape-file-capf: Add company-prefix-length=t after slash (Fix #8), ELPA Syncer, 2022/01/09
- [elpa] externals/cape e2fd7c1cc6 038/146: Minor refactoring, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 3beed4f37c 047/146: Use cape--silent, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 12f5ae008c 051/146: Update README, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 1b4b739639 059/146: Refactoring, ELPA Syncer, 2022/01/09
- [elpa] externals/cape b63deab5af 058/146: cape--cached-table: Add category, ELPA Syncer, 2022/01/09