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

Changeset 3976

Show
Ignore:
Timestamp:
10/05/08 15:45:43 (2 months ago)
Author:
kris
Message:

fixed shared seed

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tango/math/random/Twister.d

    r3975 r3976  
    1515module tango.math.random.Twister; 
    1616 
     17 
     18version (Win32) 
     19         private extern(Windows) int QueryPerformanceCounter (ulong *); 
     20 
     21version (Posix) 
     22        { 
     23        private import tango.stdc.posix.sys.time; 
     24        } 
     25         
    1726/******************************************************************************* 
    1827 
     
    7180        static this () 
    7281        { 
    73                 shared.seed (cast(uint) &shared)
     82                shared.seed
    7483        } 
    7584 
     
    8392        { 
    8493                Twister rand; 
    85                 rand.seed (cast(uint) &rand)
     94                rand.seed
    8695                return rand; 
    8796        } 
     
    199208        } 
    200209         
     210        /********************************************************************** 
     211 
     212                Seed the generator with current time 
     213 
     214        **********************************************************************/ 
     215 
     216        void seed () 
     217        { 
     218                ulong s; 
     219 
     220                version (Posix) 
     221                        { 
     222                        timeval tv; 
     223 
     224                        gettimeofday (&tv, null); 
     225                        s = tv.tv_usec; 
     226                        } 
     227                version (Win32) 
     228                         QueryPerformanceCounter (&s); 
     229 
     230                return seed (cast(uint) s); 
     231        } 
     232 
    201233        /********************************************************************** 
    202234