Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/thread.cfa

    r2210cfc r24e321c  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan 10 17:05:35 2022
    13 // Update Count     : 28
     12// Last Modified On : Wed Dec  4 09:17:49 2019
     13// Update Count     : 9
    1414//
    1515
     
    2727uint64_t thread_rand();
    2828
    29 extern uint32_t __thread_seed;                                                  // global thread seed
    30 
    3129//-----------------------------------------------------------------------------
    3230// Thread ctors and dtors
    33 void ?{}( thread$ & this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) {
     31void ?{}(thread$ & this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) {
    3432        context{ 0p, 0p };
    3533        self_cor{ name, storage, storageSize };
     
    4139        self_mon.owner = &this;
    4240        self_mon.recursion = 1;
    43         random_state = __thread_seed;
    4441        self_mon_p = &self_mon;
    4542        curr_cluster = &cl;
     
    181178}
    182179
    183 #define GENERATOR LCG
    184 
    185 inline uint32_t MarsagliaXor( uint32_t & state ) {
    186         state ^= state << 6;
    187         state ^= state >> 21;
    188         state ^= state << 7;
    189         return state;
    190 } // MarsagliaXor
    191 
    192 inline uint32_t LCG( uint32_t & state ) {                               // linear congruential generator
    193         return state = 36969 * (state & 65535) + (state >> 16); // 36969 is NOT prime!
    194 } // LCG
    195 
    196 void set_seed( uint32_t seed ) { active_thread()->random_state = seed; __thread_seed = seed; }
    197 uint32_t prng( void ) { return GENERATOR( active_thread()->random_state ); } // [0,UINT_MAX]
    198 
    199180// Local Variables: //
    200181// mode: c //
Note: See TracChangeset for help on using the changeset viewer.