1 /* 2 * uhub - A tiny ADC p2p connection hub 3 * Copyright (C) 2007-2014, Jan Vidar Krey 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 20 #ifndef HAVE_UHUB_UTIL_THREADS_H 21 #define HAVE_UHUB_UTIL_THREADS_H 22 23 typedef void*(*uhub_thread_start)(void*) ; 24 25 #ifdef POSIX_THREAD_SUPPORT 26 typedef struct pthread_data uhub_thread_t; 27 typedef pthread_mutex_t uhub_mutex_t; 28 #endif 29 30 #ifdef WINTHREAD_SUPPORT 31 struct winthread_data; 32 typedef struct winthread_data uhub_thread_t; 33 typedef CRITICAL_SECTION uhub_mutex_t; 34 #endif 35 36 // Mutexes 37 extern void uhub_mutex_init(uhub_mutex_t* mutex); 38 extern void uhub_mutex_destroy(uhub_mutex_t* mutex); 39 extern void uhub_mutex_lock(uhub_mutex_t* mutex); 40 extern void uhub_mutex_unlock(uhub_mutex_t* mutex); 41 extern int uhub_mutex_trylock(uhub_mutex_t* mutex); 42 43 // Threads 44 uhub_thread_t* uhub_thread_create(uhub_thread_start start, void* arg); 45 void uhub_thread_cancel(uhub_thread_t* thread); 46 void* uhub_thread_join(uhub_thread_t* thread); 47 48 #endif /* HAVE_UHUB_UTIL_THREADS_H */ 49 50