[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] feature/tramp-thread-safe d7f3187 6/7: Improve vc-mutex us
From: |
Michael Albinus |
Subject: |
[Emacs-diffs] feature/tramp-thread-safe d7f3187 6/7: Improve vc-mutex use |
Date: |
Sat, 4 Aug 2018 06:50:11 -0400 (EDT) |
branch: feature/tramp-thread-safe
commit d7f3187c2ec6f1290dd8471b425b814201ae8810
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>
Improve vc-mutex use
* lisp/files.el (find-file-with-threads): Don't lock `vc-mutex'
here ...
(find-file-noselect): ... but here when wildcards are enabled.
* lisp/vc/vc-hooks.el (vc-refresh-state): Lock `vc-mutex' only at
thread start. Use buffer name as thread name.
---
lisp/files.el | 18 ++++----
lisp/vc/vc-hooks.el | 123 ++++++++++++++++++++++++++--------------------------
2 files changed, 69 insertions(+), 72 deletions(-)
diff --git a/lisp/files.el b/lisp/files.el
index 128648f..195694a 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -1591,12 +1591,7 @@ If WILDCARDS is non-nil, return the spec (<filename> t
<async>)."
(declare (indent 2) (debug t))
`(if ,async
(progn
- (make-thread
- ;; We use `vc-mutex' here in order to let all
- ;; `vc-refresh-state' run after the file visiting
- ;; operations.
- (lambda () (with-mutex vc-mutex ,@body))
- (concat "find-file " ,filename))
+ (make-thread (lambda () ,@body) (concat "find-file " ,filename))
(thread-yield))
,@body))
@@ -2216,10 +2211,13 @@ every file will be loaded in an own thread."
(lambda () (find-file-noselect file))
(concat "find-file-noselect " file)))
files))
- ;; Collect the results.
- (thread-yield)
- (dolist (thread threads result)
- (setq result (cons (thread-join thread) result))))
+ ;; Collect the results. We use `vc-mutex' here in
+ ;; order to let all `vc-refresh-state' threads run
+ ;; after the file visiting operations.
+ (with-mutex vc-mutex
+ (thread-yield)
+ (dolist (thread threads result)
+ (setq result (cons (thread-join thread) result)))))
(mapcar #'find-file-noselect files))))
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index 1d572c1..59c66e7 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -814,70 +814,69 @@ In the latter case, VC mode is deactivated for this
buffer."
;; Run it asynchronously.
(make-thread
(lambda ()
- ;; Don't let the vc operations disturb each other. Delay this
- ;; after all find-file* operations have finished.
- (with-mutex vc-mutex
- (vc-file-clearprops buffer-file-name)
- ;; FIXME: Why use a hook? Why pass it buffer-file-name?
- (add-hook 'vc-mode-line-hook 'vc-mode-line nil t)
- (let (backend)
- (cond
- ((setq backend (with-demoted-errors (vc-backend buffer-file-name)))
- ;; Let the backend setup any buffer-local things he needs.
- (vc-call-backend backend 'find-file-hook)
- ;; Compute the state and put it in the mode line.
- (vc-mode-line buffer-file-name backend)
- (unless vc-make-backup-files
- ;; Use this variable, not make-backup-files,
- ;; because this is for things that depend on the file name.
- (set (make-local-variable 'backup-inhibited) t)))
- ((let* ((truename (and buffer-file-truename
- (expand-file-name buffer-file-truename)))
- (link-type (and truename
- (not (equal buffer-file-name truename))
- (vc-backend truename))))
- (cond ((not link-type) nil) ;Nothing to do.
- ((eq vc-follow-symlinks nil)
+ ;; Wait, until the file visitng function tells us so.
+ (with-mutex vc-mutex)
+ (vc-file-clearprops buffer-file-name)
+ ;; FIXME: Why use a hook? Why pass it buffer-file-name?
+ (add-hook 'vc-mode-line-hook 'vc-mode-line nil t)
+ (let (backend)
+ (cond
+ ((setq backend (with-demoted-errors (vc-backend buffer-file-name)))
+ ;; Let the backend setup any buffer-local things he needs.
+ (vc-call-backend backend 'find-file-hook)
+ ;; Compute the state and put it in the mode line.
+ (vc-mode-line buffer-file-name backend)
+ (unless vc-make-backup-files
+ ;; Use this variable, not make-backup-files, because this
+ ;; is for things that depend on the file name.
+ (set (make-local-variable 'backup-inhibited) t)))
+ ((let* ((truename (and buffer-file-truename
+ (expand-file-name buffer-file-truename)))
+ (link-type (and truename
+ (not (equal buffer-file-name truename))
+ (vc-backend truename))))
+ (cond ((not link-type) nil) ;Nothing to do.
+ ((eq vc-follow-symlinks nil)
+ (message
+ "Warning: symbolic link to %s-controlled source file"
+ link-type))
+ ((or (not (eq vc-follow-symlinks 'ask))
+ ;; Assume we cannot ask, default to yes.
+ noninteractive
+ ;; Copied from server-start. Seems like there
+ ;; should be a better way to ask "can we get
+ ;; user input?"...
+ (and (daemonp)
+ (null (cdr (frame-list)))
+ (eq (selected-frame) terminal-frame))
+ ;; If we already visited this file by
+ ;; following the link, don't ask again if we
+ ;; try to visit it again. GUD does that, and
+ ;; repeated questions are painful.
+ (get-file-buffer
+ (abbreviate-file-name
+ (file-chase-links buffer-file-name))))
+
+ (vc-follow-link)
+ (message "Followed link to %s" buffer-file-name)
+ (vc-refresh-state))
+ (t
+ (if (yes-or-no-p
+ (format
+ (concat
+ "Symbolic link to %s-controlled source file; "
+ "follow link? ")
+ link-type))
+ (progn (vc-follow-link)
+ (message
+ "Followed link to %s" buffer-file-name)
+ (vc-refresh-state))
(message
- "Warning: symbolic link to %s-controlled source file"
- link-type))
- ((or (not (eq vc-follow-symlinks 'ask))
- ;; Assume we cannot ask, default to yes.
- noninteractive
- ;; Copied from server-start. Seems like
- ;; there should be a better way to ask "can
- ;; we get user input?"...
- (and (daemonp)
- (null (cdr (frame-list)))
- (eq (selected-frame) terminal-frame))
- ;; If we already visited this file by
- ;; following the link, don't ask again if we
- ;; try to visit it again. GUD does that,
- ;; and repeated questions are painful.
- (get-file-buffer
- (abbreviate-file-name
- (file-chase-links buffer-file-name))))
-
- (vc-follow-link)
- (message "Followed link to %s" buffer-file-name)
- (vc-refresh-state))
- (t
- (if (yes-or-no-p
- (format
- (concat
- "Symbolic link to %s-controlled source file; "
- "follow link? ")
- link-type))
- (progn (vc-follow-link)
- (message
- "Followed link to %s" buffer-file-name)
- (vc-refresh-state))
- (message
- (concat
- "Warning: editing through the link "
- "bypasses version control")))))))))))
+ (concat
+ "Warning: editing through the link "
+ "bypasses version control"))))))))))
;; The thread name.
- (concat "vc-refresh-state " buffer-file-name))
+ (concat "vc-refresh-state " (buffer-name)))
;; Give other threads a chance to run.
(thread-yield)))
- [Emacs-diffs] feature/tramp-thread-safe updated (c6db534 -> d1f39eb), Michael Albinus, 2018/08/04
- [Emacs-diffs] feature/tramp-thread-safe 11ff7fa 5/7: Add list-threads command and thread-list-mode, Michael Albinus, 2018/08/04
- [Emacs-diffs] feature/tramp-thread-safe d7314b3 3/7: find-file-asynchronously can also be a regexp, Michael Albinus, 2018/08/04
- [Emacs-diffs] feature/tramp-thread-safe d1f39eb 7/7: Merge branch 'feature/tramp-thread-safe', Michael Albinus, 2018/08/04
- [Emacs-diffs] feature/tramp-thread-safe d7f3187 6/7: Improve vc-mutex use,
Michael Albinus <=
- [Emacs-diffs] feature/tramp-thread-safe 4615b91 4/7: Document visiting files asynchronously, Michael Albinus, 2018/08/04
- [Emacs-diffs] feature/tramp-thread-safe 4d340cd 2/7: Add find-file-asynchronously, Michael Albinus, 2018/08/04
- [Emacs-diffs] feature/tramp-thread-safe bba62df 1/7: Introducing thread-safe Tramp, Michael Albinus, 2018/08/04