Ignore:
Timestamp:
Jan 19, 2007, 1:39:33 AM (14 years ago)
Author:
titer
Message:

clean up

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/platform.c

    r1356 r1401  
    195195}
    196196
    197 void tr_threadCreate( tr_thread_t * t, void (*func)(void *), void * arg )
    198 {
    199 #ifdef SYS_BEOS
    200     *t = spawn_thread( (void *) func, "torrent-tx", B_NORMAL_PRIORITY, arg );
    201     resume_thread( *t );
    202 #else
    203     pthread_create( t, NULL, (void *) func, arg );
     197static void ThreadFunc( void * _t )
     198{
     199    tr_thread_t * t = _t;
     200
     201#ifdef SYS_BEOS
     202    /* This is required because on BeOS, SIGINT is sent to each thread,
     203       which kills them not nicely */
     204    signal( SIGINT, SIG_IGN );
     205#endif
     206
     207    tr_dbg( "Thread '%s' started", t->name );
     208    t->func( t->arg );
     209    tr_dbg( "Thread '%s' exited", t->name );
     210}
     211
     212void tr_threadCreate( tr_thread_t * t, void (*func)(void *), void * arg,
     213                      char * name )
     214{
     215    t->func = func;
     216    t->arg  = arg;
     217    t->name = strdup( name );
     218#ifdef SYS_BEOS
     219    t->thread = spawn_thread( (void *) ThreadFunc, name,
     220                              B_NORMAL_PRIORITY, t );
     221    resume_thread( t->thread );
     222#else
     223    pthread_create( &t->thread, NULL, (void *) ThreadFunc, t );
    204224#endif
    205225}
     
    209229#ifdef SYS_BEOS
    210230    long exit;
    211     wait_for_thread( *t, &exit );
    212 #else
    213     pthread_join( *t, NULL );
    214 #endif
     231    wait_for_thread( t->thread, &exit );
     232#else
     233    pthread_join( t->thread, NULL );
     234#endif
     235    tr_dbg( "Thread '%s' joined", t->name );
     236    free( t->name );
    215237}
    216238
Note: See TracChangeset for help on using the changeset viewer.