emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: User interaction from multiple threads


From: Elias Mårtenson
Subject: Re: User interaction from multiple threads
Date: Mon, 27 Aug 2018 18:53:47 +0800

On Sat, 25 Aug 2018 at 19:58, Michael Albinus <address@hidden> wrote:
Elias Mårtenson <address@hidden> writes:

Hi Elias,

> May I propose that the murex be hidden behind a function and a macro?
> The purpose of this would be to allow for the function to adviced by
> libraries that want to do something special. Something like this:
>
> (defmacro with-prompt-interaction (&body body)
>   (call-with-prompt-interaction `(lambda ()  ,@body)))
>
> (defun call-with-prompt-interaction (fn)
>   (with-mutex (interaction-mutex)
>     (funcall fn)))
>
> This would allow advices to be applied to the
> call-with-prompt-interaction function.

But then you must force everybody to use the
`call-with-prompt-interaction' function.

Well, yes. Although I'd expect new code to use ‘with-prompt-interaction’.
 
Doesn't it suffice to advice
`mutex-lock' and `mutex-unlock'? In your advice code you could check,
whether MUTEX is equal to `interaction-mutex'.

That would be possible, but looks rather ugly to me. Also, the fact that a mutex is used should be an implementation detail not visible to the user of the API. Having a dedicated function/macro pair for this is much cleaner.

Regards,
Elias

reply via email to

[Prev in Thread] Current Thread [Next in Thread]