Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 486

Show
Ignore:
Timestamp:
01/08/11 18:58:01 (14 years ago)
Author:
sean
Message:

A few Windows fixes using core.time.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/core/sync/condition.d

    r483 r486  
    156156     */ 
    157157    bool wait( Duration val ) 
    158158    in 
    159159    { 
    160160        assert( !val.isNegative ); 
    161161    } 
    162162    body 
    163163    { 
    164164        version( Win32 ) 
    165165        { 
    166             auto maxWaitMillis = milliseconds( uint.max - 1 ); 
     166            auto maxWaitMillis = dur!("msecs")( uint.max - 1 ); 
    167167 
    168168            while( val > maxWaitMillis ) 
    169169            { 
    170170                if( timedWait( cast(uint) 
    171                                maxWaitMillis.totalMilliseconds ) ) 
     171                               maxWaitMillis.total!("msecs")() ) ) 
    172172                    return true; 
    173173                val -= maxWaitMillis; 
    174174            } 
    175             return timedWait( cast(uint) val.totalMilliseconds ); 
     175            return timedWait( cast(uint) val.total!("msecs")() ); 
    176176        } 
    177177        else version( Posix ) 
    178178        { 
    179179            timespec t = void; 
    180180            mktspec( t, val ); 
    181181 
    182182            int rc = pthread_cond_timedwait( &m_hndl, m_mutexAddr, &t ); 
    183183            if( !rc ) 
    184184                return true; 
    185185            if( rc == ETIMEDOUT ) 
  • trunk/src/core/sync/semaphore.d

    r483 r486  
    156156        } 
    157157    } 
    158158     
    159159    
    160160    /** 
    161161     * Suspends the calling thread until the current count moves above zero or 
    162162     * until the supplied time period has elapsed.  If the count moves above 
    163163     * zero in this interval, then atomically decrement the count by one and 
    164164     * return true.  Otherwise, return false. 
    165165     * 
    166      * 
    167166     * Params: 
    168167     *  period = The time to wait. 
    169168     * 
    170169     * In: 
    171170     *  val must be non-negative. 
    172171     * 
    173172     * Throws: 
    174173     *  SyncException on error. 
    175174     * 
    176175     * Returns: 
     
    257256            } 
    258257        } 
    259258    } 
    260259 
    261260 
    262261    /** 
    263262     * Suspends the calling thread until the current count moves above zero or 
    264263     * until the supplied time period has elapsed.  If the count moves above 
    265264     * zero in this interval, then atomically decrement the count by one and 
    266265     * return true.  Otherwise, return false. 
    267      * 
    268266     * 
    269267     * Params: 
    270268     *  period = The time to wait, in 100 nanosecond intervals.  This value may 
    271269     *           be adjusted to equal to the maximum wait period supported by 
    272270     *           the target platform if it is too large. 
    273271     * 
    274272     * In: 
    275273     *  period must be non-negative. 
    276274     * 
    277275     * Throws: 
  • trunk/src/core/thread.d

    r484 r486  
    10601060     * 
    10611061     * Params: 
    10621062     *  val = The minimum duration the calling thread should be suspended. 
    10631063     * 
    10641064     * In: 
    10651065     *  period must be non-negative. 
    10661066     * 
    10671067     * Example: 
    10681068     * ------------------------------------------------------------------------ 
    10691069     * 
    1070      * Thread.sleep( milliseconds( 50 ) );  // sleep for 50 milliseconds 
    1071      * Thread.sleep( seconds( 5 ) );        // sleep for 5 seconds 
     1070     * Thread.sleep( dur!("msecs")( 50 ) );  // sleep for 50 milliseconds 
     1071     * Thread.sleep( dur!("seconds")( 5 ) ); // sleep for 5 seconds 
    10721072     * 
    10731073     * ------------------------------------------------------------------------ 
    10741074     */ 
    10751075    static void sleep( Duration val ) 
    10761076    in 
    10771077    { 
    10781078        assert( !val.isNegative ); 
    10791079    } 
    10801080    body 
    10811081    { 
    10821082        version( Windows ) 
    10831083        { 
    1084             auto maxSleepMillis = milliseconds( uint.max - 1 ); 
     1084            auto maxSleepMillis = dur!("msecs")( uint.max - 1 ); 
    10851085 
    10861086            // NOTE: In instances where all other threads in the process have a 
    10871087            //       lower priority than the current thread, the current thread 
    10881088            //       will not yield with a sleep time of zero.  However, unlike 
    10891089            //       yield(), the user is not asking for a yield to occur but 
    10901090            //       only for execution to suspend for the requested interval. 
    10911091            //       Therefore, expected performance may not be met if a yield 
    10921092            //       is forced upon the user. 
    10931093            while( val > maxSleepMillis ) 
    10941094            { 
    10951095                Sleep( cast(uint) 
    1096                        maxSleepMillis.totalMilliseconds ); 
     1096                       maxSleepMillis.total!("msecs")() ); 
    10971097                val -= maxSleepMillis; 
    10981098            } 
    1099             Sleep( cast(uint) val.totalMilliseconds ); 
     1099            Sleep( cast(uint) val.total!("msecs")() ); 
    11001100        } 
    11011101        else version( Posix ) 
    11021102        { 
    11031103            timespec tin  = void; 
    11041104            timespec tout = void; 
    11051105             
    11061106            if( val.total!("seconds")() > tin.tv_sec.max ) 
    11071107            { 
    11081108                tin.tv_sec  = tin.tv_sec.max; 
    11091109                tin.tv_nsec = cast(typeof(tin.tv_nsec)) val.fracSec.nsecs;