[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Fun with async processes
From: |
Emanuel Berg |
Subject: |
Re: Fun with async processes |
Date: |
Wed, 02 Feb 2022 00:10:06 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
Manuel Giraud wrote:
> (defvar count-processes 0)
> (defvar mtx (make-mutex))
Better, `defvar' then `setq' so you can reset them.
> (defun global-sentinel ()
> (with-mutex mtx
> (decf count-processes))
> (when (zerop count-processes)
> (message "Both have finished.")))
>
> (defun myrun ()
> (interactive)
> (setq count-processes (length (list (chatty) (thinker)))))
>
>
> But I'd like to avoid the global defvar if possible.
You can with lexical/static binding and a closure, see
https://dataswamp.org/~incal/emacs-init/w3m/w3m-survivor.el
--
underground experts united
https://dataswamp.org/~incal