Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-1.1
Commits
917aae76
Commit
917aae76
authored
Oct 05, 2008
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Static mutexes
parent
f79f2b1f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
2 deletions
+21
-2
include/vlc_threads.h
include/vlc_threads.h
+5
-2
src/misc/threads.c
src/misc/threads.c
+16
-0
No files found.
include/vlc_threads.h
View file @
917aae76
...
...
@@ -105,6 +105,7 @@
#if defined (LIBVLC_USE_PTHREAD)
typedef
pthread_t
vlc_thread_t
;
typedef
pthread_mutex_t
vlc_mutex_t
;
#define VLC_STATIC_MUTEX PTHREAD_MUTEX_INITIALIZER
typedef
pthread_cond_t
vlc_cond_t
;
typedef
pthread_key_t
vlc_threadvar_t
;
...
...
@@ -119,8 +120,10 @@ typedef struct
typedef
struct
{
CRITICAL_SECTION
mutex
;
}
vlc_mutex_t
;
LONG
initialized
;
}
vlc_mutex_t
;
#define VLC_STATIC_MUTEX { .initialized = 0, }
typedef
HANDLE
vlc_cond_t
;
typedef
DWORD
vlc_threadvar_t
;
...
...
src/misc/threads.c
View file @
917aae76
...
...
@@ -157,6 +157,8 @@ typedef struct vlc_cancel_t
#endif
#ifdef WIN32
static
vlc_mutex_t
super_mutex
;
BOOL
WINAPI
DllMain
(
HINSTANCE
hinstDll
,
DWORD
fdwReason
,
LPVOID
lpvReserved
)
{
(
void
)
hinstDll
;
...
...
@@ -167,11 +169,13 @@ BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
case
DLL_PROCESS_ATTACH
:
vlc_dictionary_init
(
&
named_mutexes
.
list
,
0
);
vlc_mutex_init
(
&
named_mutexes
.
lock
);
vlc_mutex_init
(
&
super_mutex
);
vlc_threadvar_create
(
&
cancel_key
,
free
);
break
;
case
DLL_PROCESS_DETACH
:
vlc_threadvar_delete
(
&
cancel_key
);
vlc_mutex_destroy
(
&
super_mutex
);
vlc_mutex_destroy
(
&
named_mutexes
.
lock
);
vlc_dictionary_clear
(
&
named_mutexes
.
list
);
break
;
...
...
@@ -238,6 +242,8 @@ int vlc_mutex_init_recursive( vlc_mutex_t *p_mutex )
#elif defined( WIN32 )
InitializeCriticalSection
(
&
p_mutex
->
mutex
);
InterlockedIncrement
(
&
p_mutex
->
initialized
);
barrier
();
return
0
;
#endif
...
...
@@ -257,6 +263,7 @@ void vlc_mutex_destroy (vlc_mutex_t *p_mutex)
VLC_THREAD_ASSERT
(
"destroying mutex"
);
#elif defined( WIN32 )
InterlockedDecrement
(
&
p_mutex
->
initialized
);
DeleteCriticalSection
(
&
p_mutex
->
mutex
);
#endif
...
...
@@ -277,6 +284,15 @@ void vlc_mutex_lock (vlc_mutex_t *p_mutex)
VLC_THREAD_ASSERT
(
"locking mutex"
);
#elif defined( WIN32 )
if
(
InterlockedCompareExchange
(
&
p_mutex
->
initialized
,
0
,
0
)
==
0
)
{
/* ^^ We could also lock super_mutex all the time... sluggish */
assert
(
p_mutex
!=
&
super_mutex
);
/* this one cannot be static */
vlc_mutex_lock
(
&
super_mutex
);
vlc_mutex_init
(
p_mutex
);
/* FIXME: destroy the mutex some time... */
vlc_mutex_unlock
(
&
super_mutex
);
}
EnterCriticalSection
(
&
p_mutex
->
mutex
);
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment