Changeset 5164


Ignore:
Timestamp:
Feb 28, 2008, 4:40:31 PM (13 years ago)
Author:
charles
Message:

better win32 thread support

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/platform.c

    r5081 r5164  
    9696    void           * arg;
    9797    const char     * name;
    98 
    99 #ifdef __BEOS__
    100     thread_id        thread;
    101 #elif defined(WIN32)
    102     HANDLE           thread;
    103     unsigned int     thread_id;
    104 #else
    105     pthread_t        thread;
    106 #endif
    107 
     98    tr_thread_id     thread;
     99#ifdef WIN32
     100    HANDLE           thread_handle;
     101#endif
    108102};
    109103
     
    148142{
    149143    tr_thread * t = tr_new0( tr_thread, 1 );
     144
     145#ifdef __BEOS__
     146    t->thread = spawn_thread( (void*)ThreadFunc, name, B_NORMAL_PRIORITY, t );
     147    resume_thread( t->thread );
     148#elif defined(WIN32)
     149    unsigned id;
     150    t->thread_handle = (HANDLE) _beginthreadex( NULL, 0, &ThreadFunc, t, 0, &id );
     151    t->thread = (DWORD) id;
     152#else
     153    pthread_create( &t->thread, NULL, (void * (*) (void *)) ThreadFunc, t );
     154#endif
    150155    t->func = func;
    151156    t->arg  = arg;
    152157    t->name = name;
    153158
    154 #ifdef __BEOS__
    155     t->thread = spawn_thread( (void*)ThreadFunc, name, B_NORMAL_PRIORITY, t );
    156     resume_thread( t->thread );
    157 #elif defined(WIN32)
    158     t->thread = (HANDLE) _beginthreadex( NULL, 0, &ThreadFunc, t, 0, &t->thread_id );
    159 #else
    160     pthread_create( &t->thread, NULL, (void * (*) (void *)) ThreadFunc, t );
    161 #endif
    162 
    163159    return t;
    164160}
     
    173169        wait_for_thread( t->thread, &exit );
    174170#elif defined(WIN32)
    175         WaitForSingleObject( t->thread, INFINITE );
    176         CloseHandle( t->thread );
     171        WaitForSingleObject( t->thread_handle, INFINITE );
     172        CloseHandle( t->thread_handle );
    177173#else
    178174        pthread_join( t->thread, NULL );
  • trunk/libtransmission/transmission.c

    r5081 r5164  
    213213tr_globalIsLocked( const struct tr_handle * handle )
    214214{
    215     return tr_lockHave( handle->lock );
     215    return handle && tr_lockHave( handle->lock );
    216216}
    217217
Note: See TracChangeset for help on using the changeset viewer.