diff options
author | megamage <none@none> | 2009-06-18 19:27:17 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-06-18 19:27:17 -0500 |
commit | a49c2982ba975a4c5dba7b1bf6a31a7c54a13c1d (patch) | |
tree | e7acd28b0fa53076221d335a9b033695f0abed2b /src/shared/Util.cpp | |
parent | fd73be2f1e2aa134f3b26277281411de691db04a (diff) | |
parent | 19225e8880b12bf3b72743ea253a94b52635a212 (diff) |
*Merge.
*mtmap is disabled by default. To use it, define MULTI_THREAD_MAP in define.h
*mtmap support is not provided for windows users. Because there is no free openmp lib for windows. If you have openmp lib and want to use openmp, you need to manually change the setting.
--HG--
branch : trunk
Diffstat (limited to 'src/shared/Util.cpp')
-rw-r--r-- | src/shared/Util.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/shared/Util.cpp b/src/shared/Util.cpp index ac57fc3c9e9..354568c778f 100644 --- a/src/shared/Util.cpp +++ b/src/shared/Util.cpp @@ -28,6 +28,60 @@ typedef ACE_TSS<MTRand> MTRandTSS; static MTRandTSS mtRand; +#ifdef MULTI_THREAD_MAP + +int32 irand (int32 min, int32 max) +{ + int32 result; +#pragma omp critical (mtrand) +{ + result = int32 (mtRand->randInt (max - min)) + min; +} + return result; +} + +uint32 urand (uint32 min, uint32 max) +{ + uint32 result; +#pragma omp critical (mtrand) +{ + result = mtRand->randInt (max - min) + min; +} + return result; +} + +int32 rand32 () +{ + int32 result; +#pragma omp critical (mtrand) +{ + result = mtRand->randInt (); +} + return result; +} + +double rand_norm(void) +{ + double result; +#pragma omp critical (mtrand) +{ + result = mtRand->randExc (); +} + return result; +} + +double rand_chance (void) +{ + double result; +#pragma omp critical (mtrand) +{ + result = mtRand->randExc (100.0); +} + return result; +} + +#else + int32 irand (int32 min, int32 max) { return int32 (mtRand->randInt (max - min)) + min; @@ -53,6 +107,8 @@ double rand_chance (void) return mtRand->randExc (100.0); } +#endif + Tokens StrSplit(const std::string &src, const std::string &sep) { Tokens r; |