diff options
author | raczman <none@none> | 2009-06-15 09:07:51 +0200 |
---|---|---|
committer | raczman <none@none> | 2009-06-15 09:07:51 +0200 |
commit | 19225e8880b12bf3b72743ea253a94b52635a212 (patch) | |
tree | 6ad5d22134939c7bed0aa1d95d68f354241a5654 /src/shared/Util.cpp | |
parent | 98c8b762b7de97f89ce072e6bd8ace2b832d0742 (diff) |
Added basic support for multithreaded map updates using openmp standard.
Windows users need to install Platform SDK to use this feature,
linux users have everything they need in gcc.
Number of threads used to update world is set by confiuration file,
and can be changed dynamically without restarting core.
Thanks to megamage and Jeniczek for testing and helping out with this.
--HG--
branch : trunk
Diffstat (limited to 'src/shared/Util.cpp')
-rw-r--r-- | src/shared/Util.cpp | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/src/shared/Util.cpp b/src/shared/Util.cpp index 26d2275ec2a..4624cacfde7 100644 --- a/src/shared/Util.cpp +++ b/src/shared/Util.cpp @@ -36,27 +36,52 @@ static MTRandTSS mtRand; int32 irand (int32 min, int32 max) { - return int32 (mtRand.get ().randInt (max - min)) + min; + int32 result; +#pragma omp critical (mtrand) +{ + result = mtRand.get ().randInt (max-min) + min; +} + return result; } uint32 urand (uint32 min, uint32 max) { - return mtRand.get ().randInt (max - min) + min; + uint32 result; +#pragma omp critical (mtrand) +{ + result = mtRand.get ().randInt (max - min) + min; +} + return result; } int32 rand32 () { - return mtRand.get ().randInt (); + int32 result; +#pragma omp critical (mtrand) +{ + result = mtRand.get ().randInt (); +} + return result; } double rand_norm(void) { - return mtRand.get ().randExc (); + double result; +#pragma omp critical (mtrand) +{ + result = mtRand.get ().randExc (); +} + return result; } double rand_chance (void) { - return mtRand.get ().randExc (100.0); + double result; +#pragma omp critical (mtrand) +{ + result = mtRand.get ().randExc (100.0); +} + return result; } Tokens StrSplit(const std::string &src, const std::string &sep) |