[vlc-commits] [Git][videolan/vlc][master] threads: move non-exported calls out of vlc_threads.h

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Nov 30 09:00:28 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
ebf64607 by Steve Lhomme at 2023-11-30T08:45:25+00:00
threads: move non-exported calls out of vlc_threads.h

- - - - -


6 changed files:

- include/vlc_threads.h
- src/Makefile.am
- src/input/vlm.c
- src/misc/threads.c
- + src/misc/threads.h
- src/video_output/video_output.c


Changes:

=====================================
include/vlc_threads.h
=====================================
@@ -398,8 +398,6 @@ VLC_API void vlc_cond_wait(vlc_cond_t *cond, vlc_mutex_t *mutex);
 VLC_API int vlc_cond_timedwait(vlc_cond_t *cond, vlc_mutex_t *mutex,
                                vlc_tick_t deadline);
 
-int vlc_cond_timedwait_daytime(vlc_cond_t *, vlc_mutex_t *, time_t);
-
 /** @} */
 
 /**
@@ -567,50 +565,6 @@ VLC_API void vlc_latch_wait(vlc_latch_t *);
 
 /** @} */
 
-/*
- * Queued mutex
- *
- * A queued mutex is a type of thread-safe mutual exclusion lock that is
- * acquired in strict FIFO order.
- *
- * In most cases, a regular mutex (\ref vlc_mutex_t) should be used instead.
- * There are important differences:
- * - A queued mutex is generally slower, especially on the fast path.
- * - A queued mutex cannot be combined with a condition variable.
- *   Indeed, the scheduling policy of the condition variable would typically
- *   conflict with that of the queued mutex, leading to a dead lock.
- * - The try-lock operation is not implemented.
- */
-typedef struct {
-    atomic_uint head;
-    atomic_uint tail;
-    atomic_ulong owner;
-} vlc_queuedmutex_t;
-
-#define VLC_STATIC_QUEUEDMUTEX { ATOMIC_VAR_INIT(0), ATOMIC_VAR_INIT(0), ATOMIC_VAR_INIT(0) }
-
-void vlc_queuedmutex_init(vlc_queuedmutex_t *m);
-
-void vlc_queuedmutex_lock(vlc_queuedmutex_t *m);
-
-void vlc_queuedmutex_unlock(vlc_queuedmutex_t *m);
-
-/**
- * Checks if a queued mutex is locked.
- *
- * This function checks if the calling thread holds a given queued mutual
- * exclusion lock. It has no side effects and is essentially intended for
- * run-time debugging.
- *
- * @note To assert that the calling thread holds a lock, the helper macro
- * vlc_queuedmutex_assert() should be used instead of this function.
- *
- * @retval false the mutex is not locked by the calling thread
- * @retval true the mutex is locked by the calling thread
- */
-bool vlc_queuedmutex_held(vlc_queuedmutex_t *m);
-
-#define vlc_queuedmutex_assert(m) assert(vlc_queuedmutex_held(m))
 /**
  * One-time initialization.
  *


=====================================
src/Makefile.am
=====================================
@@ -391,6 +391,7 @@ libvlccore_la_SOURCES = \
 	misc/rcu.c \
 	misc/renderer_discovery.c \
 	misc/threads.c \
+	misc/threads.h \
 	misc/cpu.c \
 	misc/diffutil.c \
 	misc/epg.c \


=====================================
src/input/vlm.c
=====================================
@@ -47,6 +47,7 @@
 #include "vlm_event.h"
 #include <vlc_sout.h>
 #include <vlc_url.h>
+#include "../misc/threads.h"
 #include "../libvlc.h"
 
 /*****************************************************************************
@@ -976,4 +977,3 @@ int vlm_Control( vlm_t *p_vlm, int i_query, ... )
 
     return i_result;
 }
-


=====================================
src/misc/threads.c
=====================================
@@ -31,6 +31,7 @@
 #include <vlc_threads.h>
 #include <vlc_atomic.h>
 #include "libvlc.h"
+#include "threads.h"
 
 /* <stdatomic.h> types cannot be used in the C++ view of <vlc_threads.h> */
 struct vlc_suuint { union { unsigned int value; }; };


=====================================
src/misc/threads.h
=====================================
@@ -0,0 +1,79 @@
+/*****************************************************************************
+ * threads.h : core internal threads implementation for the VideoLAN client
+ *****************************************************************************
+ * Copyright (C) 1999, 2002 VLC authors and VideoLAN
+ * Copyright © 2007-2016 Rémi Denis-Courmont
+ *
+ * Authors: Jean-Marc Dressler <polux at via.ecp.fr>
+ *          Samuel Hocevar <sam at via.ecp.fr>
+ *          Gildas Bazin <gbazin at netcourrier.com>
+ *          Christophe Massiot <massiot at via.ecp.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifndef VLC_CORE_THREADS_H_
+#define VLC_CORE_THREADS_H_
+
+#include <vlc_threads.h>
+
+int vlc_cond_timedwait_daytime(vlc_cond_t *, vlc_mutex_t *, time_t);
+
+/*
+ * Queued mutex
+ *
+ * A queued mutex is a type of thread-safe mutual exclusion lock that is
+ * acquired in strict FIFO order.
+ *
+ * In most cases, a regular mutex (\ref vlc_mutex_t) should be used instead.
+ * There are important differences:
+ * - A queued mutex is generally slower, especially on the fast path.
+ * - A queued mutex cannot be combined with a condition variable.
+ *   Indeed, the scheduling policy of the condition variable would typically
+ *   conflict with that of the queued mutex, leading to a dead lock.
+ * - The try-lock operation is not implemented.
+ */
+typedef struct {
+    atomic_uint head;
+    atomic_uint tail;
+    atomic_ulong owner;
+} vlc_queuedmutex_t;
+
+#define VLC_STATIC_QUEUEDMUTEX { ATOMIC_VAR_INIT(0), ATOMIC_VAR_INIT(0), ATOMIC_VAR_INIT(0) }
+
+void vlc_queuedmutex_init(vlc_queuedmutex_t *m);
+
+void vlc_queuedmutex_lock(vlc_queuedmutex_t *m);
+
+void vlc_queuedmutex_unlock(vlc_queuedmutex_t *m);
+
+/**
+ * Checks if a queued mutex is locked.
+ *
+ * This function checks if the calling thread holds a given queued mutual
+ * exclusion lock. It has no side effects and is essentially intended for
+ * run-time debugging.
+ *
+ * @note To assert that the calling thread holds a lock, the helper macro
+ * vlc_queuedmutex_assert() should be used instead of this function.
+ *
+ * @retval false the mutex is not locked by the calling thread
+ * @retval true the mutex is locked by the calling thread
+ */
+bool vlc_queuedmutex_held(vlc_queuedmutex_t *m);
+
+#define vlc_queuedmutex_assert(m) assert(vlc_queuedmutex_held(m))
+
+#endif /* !VLC_CORE_THREADS_H_ */


=====================================
src/video_output/video_output.c
=====================================
@@ -60,6 +60,7 @@
 #include "snapshot.h"
 #include "video_window.h"
 #include "../misc/variables.h"
+#include "../misc/threads.h"
 #include "../clock/clock.h"
 #include "statistic.h"
 #include "chrono.h"



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/ebf6460753ef6c08181873ec3a5d789c202a6234

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/ebf6460753ef6c08181873ec3a5d789c202a6234
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list