summaryrefslogtreecommitdiffstats
path: root/src/thread.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2017-11-05 16:14:32 +0100
committerGravatar Nikias Bassen2017-11-05 16:14:32 +0100
commitf9b529b75982902c9b31ee59fe73e2c56b8ba237 (patch)
tree3c2a442801161040ac0aad25a67abfad6cc764ee /src/thread.c
parent22743f7d85380ec68af2b7c94fab110d4b611969 (diff)
downloadidevicerestore-f9b529b75982902c9b31ee59fe73e2c56b8ba237.tar.gz
idevicerestore-f9b529b75982902c9b31ee59fe73e2c56b8ba237.tar.bz2
thread: Add 'thread_alive' helper
Diffstat (limited to 'src/thread.c')
-rw-r--r--src/thread.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/thread.c b/src/thread.c
index fdc8112..b84ee66 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -53,6 +53,17 @@ void thread_join(thread_t thread)
#endif
}
+int thread_alive(thread_t thread)
+{
+ if (!thread)
+ return 0;
+#ifdef WIN32
+ return WaitForSingleObject(thread, 0) == WAIT_TIMEOUT;
+#else
+ return pthread_kill(thread, 0) == 0;
+#endif
+}
+
void mutex_init(mutex_t* mutex)
{
#ifdef WIN32