Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changeset 2335

Show
Ignore:
Timestamp:
06/19/07 13:35:42 (1 year ago)
Author:
sean
Message:

More changes for linux compatibility. I hadn't realized that timeouts were absolute (instead of relative). Utility routines will live in tango.core.sync.Config.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tango/core/sync/Condition.d

    r2334 r2335  
    2121else version( Posix ) 
    2222{ 
     23    private import tango.core.sync.Config; 
    2324    private import tango.stdc.errno; 
    2425    private import tango.stdc.posix.pthread; 
     
    154155            timespec t; 
    155156 
    156             if( period > t.tv_sec.max ) 
    157             { 
    158                 t.tv_sec  = t.tv_sec.max; 
    159                 t.tv_nsec = t.tv_nsec.max; 
    160             } 
    161             else 
    162             { 
    163                 t.tv_sec  = cast(typeof(t.tv_sec)) period; 
    164                 t.tv_nsec = cast(typeof(t.tv_sec))( ( period - t.tv_sec ) * 1_000_000 ); 
    165             } 
    166  
    167             int rc = pthread_cond_timedwait( &m_hndl, m_mutexAddr, &t ); 
    168             switch( rc ) 
     157            setTimespec( t, absTimeout( period ) ); 
     158            switch( pthread_cond_timedwait( &m_hndl, m_mutexAddr, &t ) ) 
    169159            { 
    170160            case ETIMEDOUT: 
  • trunk/tango/core/sync/Semaphore.d

    r2333 r2335  
    1818else version( Posix ) 
    1919{ 
     20    private import tango.core.sync.Config; 
    2021    private import tango.stdc.errno; 
    2122    private import tango.stdc.posix.pthread; 
     
    155156            timespec t; 
    156157 
    157             if( period > t.tv_sec.max ) 
    158             { 
    159                 t.tv_sec  = t.tv_sec.max; 
    160                 t.tv_nsec = t.tv_nsec.max; 
    161             } 
    162             else 
    163             { 
    164                 t.tv_sec  = cast(typeof(t.tv_sec)) period; 
    165                 t.tv_nsec = cast(typeof(t.tv_sec))( ( period - t.tv_sec ) * 1_000_000 ); 
    166             } 
    167  
    168             int rc = sem_timedwait( &m_hndl, &t ); 
    169             switch( rc ) 
     158            setTimespec( t, absTimeout( period ) ); 
     159            switch( sem_timedwait( &m_hndl, &t ) ) 
    170160            { 
    171161            case ETIMEDOUT: