Given code such as
(defun some-code () (url-retrieve my-url #'my-callback) (setq *a-global-var* (some-func *a-global-var*)) ...) (defun my-callback (status &rest args) (setq *a-global-var* (another-func *a-global-var*)))
How can I ensure that the two updates of
*a-global-var* happen atomically? In other words, how can I prevent the callback from changing
some-func is running? I searched the Emacs documentation for a while, but I didn't find anything on the semantics of asynchronous operations.
url-httpwhich uses sentinels for the callback. Sentinels only run when emacs is waiting for user input. See: the section Sentinels of the elisp-documentation. So you do not have the problem of non-atomic writes to a variable.