Browse Source

threads: move non-exported calls out of vlc_threads.h

pull/162/head
Steve Lhomme 3 years ago
parent
commit
ebf6460753
  1. 46
      include/vlc_threads.h
  2. 1
      src/Makefile.am
  3. 2
      src/input/vlm.c
  4. 1
      src/misc/threads.c
  5. 79
      src/misc/threads.h
  6. 1
      src/video_output/video_output.c

46
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.
*

1
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 \

2
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;
}

1
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; }; };

79
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@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr>
* Gildas Bazin <gbazin@netcourrier.com>
* Christophe Massiot <massiot@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_ */

1
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"

Loading…
Cancel
Save