Last active
June 23, 2025 12:56
-
-
Save kiennq/cfe57671bab3300d3ed849a7cbf2927c to your computer and use it in GitHub Desktop.
Revisions
-
kiennq revised this gist
Nov 30, 2019 . 1 changed file with 9 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,21 +12,20 @@ (require 'cl-lib)) (defvar async-maximum-parallel-procs 4) (defvar async--parallel-procs 0) (defvar async--queue nil) (defvar-local async--cb nil) (advice-add #'async-start :around (lambda (orig-func func &optional callback) (if (>= async--parallel-procs async-maximum-parallel-procs) (push `(,func ,callback) async--queue) (cl-incf async--parallel-procs) (let ((future (funcall orig-func func (lambda (re) (cl-decf async--parallel-procs) (when async--cb (funcall async--cb re)) (when-let (args (pop async--queue)) (apply #'async-start args)))))) (with-current-buffer (process-buffer future) (setq async--cb callback))))) '((name . --queue-dispatch))) ) -
kiennq created this gist
Nov 22, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ (use-package async :ensure t :defer 5 :init (setq async-bytecomp-allowed-packages '(all)) :config ;; async compiling package (async-bytecomp-package-mode t) (dired-async-mode 1) ;; limit number of async processes (eval-when-compile (require 'cl-lib)) (defvar async-maximum-parallel-procs 4) (defvar async--parallel-procs 0) (defvar async--queue nil "Queue of (func callback) that is waited for being dispatched async.") (defvar-local async--cb nil) (advice-add #'async-start :around (lambda (orig-func func &optional callback) (if (>= async--parallel-procs async-maximum-parallel-procs) (push `(,func ,callback) async--queue) (cl-incf async--parallel-procs) (setq async--cb callback) (funcall orig-func func (lambda (re) (message "done: %s" re) (cl-decf async--parallel-procs) (when async--cb (funcall async--cb re)) (when-let ((args (pop async--queue))) (apply #'async-start args)))))) '((name . --queue-dispatch))) )