[vlc-devel] [PATCH] threads: make vlc_cleanup_push call the cleanup function in C++ on Win32/OS2
Steve Lhomme
robux4 at ycbcr.xyz
Mon Feb 10 16:06:38 CET 2020
On 2020-02-10 15:53, Rémi Denis-Courmont wrote:
> Hi,
>
> This is missing unwinding code for C++. The removed comments are there
> for reasons...
Isn't that a problem of the routine called, rather than storing the
routine ? In that case we may impose some restrictions on the routine
(via strong typing).
It seems throwing an exception in the routine might be a good way to do
things cleanly.
> Le 10 février 2020 15:55:44 GMT+02:00, Steve Lhomme <robux4 at ycbcr.xyz> a
> écrit :
>
> Should fix #23591
> ------------------------------------------------------------------------
> include/vlc_threads.h | 12 ++----------
> 1 file changed, 2 insertions(+), 10 deletions(-)
>
> diff --git a/include/vlc_threads.h b/include/vlc_threads.h
> index 0e27ea803fa..b2ef5222d3b 100644
> --- a/include/vlc_threads.h
> +++ b/include/vlc_threads.h
> @@ -1071,26 +1071,18 @@ struct vlc_cleanup_t
> void *data;
> };
>
> -# ifndef __cplusplus
> /* This macros opens a code block on purpose: It reduces the chance of
> * not pairing the push and pop. It also matches the POSIX Thread internals.
> * That way, Win32 developers will not accidentally break other platforms.
> */
> # define vlc_cleanup_push( routine, arg ) \
> do { \
> - vlc_control_cancel(&(vlc_cleanup_t){ NULL, routine, arg })
> + vlc_cleanup_t _cleanup = (vlc_cleanup_t){ NULL, routine, arg }; \
> + vlc_control_cancel(&_cleanup)
>
> # define vlc_cleanup_pop( ) \
> vlc_control_cancel (NULL); \
> } while (0)
> -# else
> -/* Those macros do not work in C++. However common C/C++ helpers may call them
> - * anyway - this is fine if the code is never cancelled in C++ case.
> - * So define the macros to do nothing.
> - */
> -# define vlc_cleanup_push(routine, arg) do { (routine, arg)
> -# define vlc_cleanup_pop() } while (0)
> -# endif
>
> #endif /* !LIBVLC_USE_PTHREAD_CLEANUP */
>
>
>
> --
> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser
> ma brièveté.
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
More information about the vlc-devel
mailing list