Commit 8aa498b7 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Win32: remove useless variable atomicity

parent f59907f1
...@@ -417,7 +417,11 @@ struct vlc_thread ...@@ -417,7 +417,11 @@ struct vlc_thread
HANDLE id; HANDLE id;
bool killable; bool killable;
#if !VLC_WINSTORE_APP
bool killed;
#else
atomic_bool killed; atomic_bool killed;
#endif
vlc_cleanup_t *cleaners; vlc_cleanup_t *cleaners;
void *(*entry) (void *); void *(*entry) (void *);
...@@ -479,7 +483,11 @@ static int vlc_clone_attr (vlc_thread_t *p_handle, bool detached, ...@@ -479,7 +483,11 @@ static int vlc_clone_attr (vlc_thread_t *p_handle, bool detached,
th->entry = entry; th->entry = entry;
th->data = data; th->data = data;
th->killable = false; /* not until vlc_entry() ! */ th->killable = false; /* not until vlc_entry() ! */
atomic_store(&th->killed, false); #if !VLC_WINSTORE_APP
th->killed = false;
#else
atomic_init(&th->killed, false);
#endif
th->cleaners = NULL; th->cleaners = NULL;
/* When using the MSVCRT C library you have to use the _beginthreadex /* When using the MSVCRT C library you have to use the _beginthreadex
...@@ -551,18 +559,21 @@ int vlc_set_priority (vlc_thread_t th, int priority) ...@@ -551,18 +559,21 @@ int vlc_set_priority (vlc_thread_t th, int priority)
#if !VLC_WINSTORE_APP #if !VLC_WINSTORE_APP
/* APC procedure for thread cancellation */ /* APC procedure for thread cancellation */
static void CALLBACK dummy_apc (ULONG_PTR self) static void CALLBACK vlc_cancel_self (ULONG_PTR self)
{ {
(void)self; struct vlc_thread *th = (void *)self;
/* Cancelled thread will wake up of alertable state */
if (likely(th != NULL))
th->killed = true;
} }
#endif #endif
void vlc_cancel (vlc_thread_t th) void vlc_cancel (vlc_thread_t th)
{ {
atomic_store(&th->killed, true);
#if !VLC_WINSTORE_APP #if !VLC_WINSTORE_APP
QueueUserAPC (dummy_apc, th->id, 0); QueueUserAPC (vlc_cancel_self, th->id, (uintptr_t)th);
#else
atomic_store (&th->killed, true);
#endif #endif
} }
...@@ -594,16 +605,22 @@ void vlc_testcancel (void) ...@@ -594,16 +605,22 @@ void vlc_testcancel (void)
struct vlc_thread *th = vlc_threadvar_get (thread_key); struct vlc_thread *th = vlc_threadvar_get (thread_key);
if (th == NULL) if (th == NULL)
return; /* Main thread - cannot be cancelled anyway */ return; /* Main thread - cannot be cancelled anyway */
if (!th->killable)
return;
#if !VLC_WINSTORE_APP
if (likely(!th->killed))
return;
#else
if (!atomic_load(&th->killed))
return;
#endif
if (th->killable && atomic_load(&th->killed)) for (vlc_cleanup_t *p = th->cleaners; p != NULL; p = p->next)
{ p->proc (p->data);
for (vlc_cleanup_t *p = th->cleaners; p != NULL; p = p->next)
p->proc (p->data);
th->data = NULL; /* TODO: special value? */ th->data = NULL; /* TODO: special value? */
vlc_thread_cleanup (th); vlc_thread_cleanup (th);
_endthreadex(0); _endthreadex(0);
}
} }
void vlc_control_cancel (int cmd, ...) void vlc_control_cancel (int cmd, ...)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment