summaryrefslogtreecommitdiffstats
path: root/libhb/ports.c
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2012-05-17 19:51:35 +0000
committerjstebbins <[email protected]>2012-05-17 19:51:35 +0000
commit5a0673d1572fdfcd00063cfa9dffba907c808056 (patch)
treeb55af15b31edc30a69bf2c17818f6ea3565f9a9a /libhb/ports.c
parentd005ce0b526630bd428c1e5a466b0a96f0b8ecba (diff)
libhb: tasksets API provided by scsiguy
This is an easier to use API for launching multithreaded tasks. And it is more portable since it does not rely on undefined/implementation specific behavior of POSIX mutexes. That is, the ability for one thread to unlock a mutex owned by another thread. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4685 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/ports.c')
-rw-r--r--libhb/ports.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/libhb/ports.c b/libhb/ports.c
index cec4efd96..6f3a48240 100644
--- a/libhb/ports.c
+++ b/libhb/ports.c
@@ -294,20 +294,20 @@ void hb_mkdir( char * name )
***********************************************************************/
struct hb_thread_s
{
- char * name;
- int priority;
- void (* function) ( void * );
- void * arg;
+ char * name;
+ int priority;
+ thread_func_t * function;
+ void * arg;
- hb_lock_t * lock;
- int exited;
+ hb_lock_t * lock;
+ int exited;
#if defined( SYS_BEOS )
- thread_id thread;
+ thread_id thread;
#elif USE_PTHREAD
- pthread_t thread;
+ pthread_t thread;
//#elif defined( SYS_CYGWIN )
-// HANDLE thread;
+// HANDLE thread;
#endif
};
@@ -346,7 +346,7 @@ static void attribute_align_thread hb_thread_func( void * _t )
{
hb_thread_t * t = (hb_thread_t *) _t;
-#if defined( SYS_DARWIN )
+#if defined( SYS_DARWIN ) || defined( SYS_FREEBSD )
/* Set the thread priority */
struct sched_param param;
memset( &param, 0, sizeof( struct sched_param ) );
@@ -376,7 +376,7 @@ static void attribute_align_thread hb_thread_func( void * _t )
* arg: argument of the routine
* priority: HB_LOW_PRIORITY or HB_NORMAL_PRIORITY
***********************************************************************/
-hb_thread_t * hb_thread_init( char * name, void (* function)(void *),
+hb_thread_t * hb_thread_init( const char * name, void (* function)(void *),
void * arg, int priority )
{
hb_thread_t * t = calloc( sizeof( hb_thread_t ), 1 );
@@ -489,7 +489,7 @@ hb_lock_t * hb_lock_init()
pthread_mutexattr_init(&mta);
-#if defined( SYS_CYGWIN )
+#if defined( SYS_CYGWIN ) || defined( SYS_FREEBSD )
pthread_mutexattr_settype(&mta, PTHREAD_MUTEX_NORMAL);
#endif
@@ -566,6 +566,9 @@ hb_cond_t * hb_cond_init()
{
hb_cond_t * c = calloc( sizeof( hb_cond_t ), 1 );
+ if( c == NULL )
+ return NULL;
+
#if defined( SYS_BEOS )
c->thread = -1;
#elif USE_PTHREAD