Replaced Threading and SFMT access related code with std::thread and boost TSS
Note: The remote access thread is currently broken due to unknown ACE fail (will be replaced at some point anyways..)
This commit is contained in:
1 parent
55dee85ed8
commit
33dc72a812
16 files changed
+140
-567
No files matched your search
@@ -21,42 +21,54 @@
|
||||
#include "utf8.h"
|
||||
#include "SFMT.h"
|
||||
#include "Errors.h" // for ASSERT
|
||||
#include <ace/TSS_T.h>
|
||||
#include <boost/thread/tss.hpp>
|
||||
|
||||
typedef ACE_TSS<SFMTRand> SFMTRandTSS;
|
||||
static SFMTRandTSS sfmtRand;
|
||||
static boost::thread_specific_ptr<SFMTRand> sfmtRand;
|
||||
|
||||
static SFMTRand* GetRng()
|
||||
{
|
||||
SFMTRand* rand = sfmtRand.get();
|
||||
|
||||
if (!rand)
|
||||
{
|
||||
rand = new SFMTRand();
|
||||
sfmtRand.reset(rand);
|
||||
}
|
||||
|
||||
return rand;
|
||||
}
|
||||
|
||||
int32 irand(int32 min, int32 max)
|
||||
{
|
||||
ASSERT(max >= min);
|
||||
return int32(sfmtRand->IRandom(min, max));
|
||||
return int32(GetRng()->IRandom(min, max));
|
||||
}
|
||||
|
||||
uint32 urand(uint32 min, uint32 max)
|
||||
{
|
||||
ASSERT(max >= min);
|
||||
return sfmtRand->URandom(min, max);
|
||||
return GetRng()->URandom(min, max);
|
||||
}
|
||||
|
||||
float frand(float min, float max)
|
||||
{
|
||||
ASSERT(max >= min);
|
||||
return float(sfmtRand->Random() * (max - min) + min);
|
||||
return float(GetRng()->Random() * (max - min) + min);
|
||||
}
|
||||
|
||||
int32 rand32()
|
||||
{
|
||||
return int32(sfmtRand->BRandom());
|
||||
return int32(GetRng()->BRandom());
|
||||
}
|
||||
|
||||
double rand_norm(void)
|
||||
{
|
||||
return sfmtRand->Random();
|
||||
return GetRng()->Random();
|
||||
}
|
||||
|
||||
double rand_chance(void)
|
||||
{
|
||||
return sfmtRand->Random() * 100.0;
|
||||
return GetRng()->Random() * 100.0;
|
||||
}
|
||||
|
||||
Tokenizer::Tokenizer(const std::string &src, const char sep, uint32 vectorReserve)
|
||||
@@ -250,13 +262,6 @@ bool IsIPAddress(char const* ipaddress)
|
||||
return inet_addr(ipaddress) != INADDR_NONE;
|
||||
}
|
||||
|
||||
std::string GetAddressString(ACE_INET_Addr const& addr)
|
||||
{
|
||||
char buf[ACE_MAX_FULLY_QUALIFIED_NAME_LEN + 16];
|
||||
addr.addr_to_string(buf, ACE_MAX_FULLY_QUALIFIED_NAME_LEN + 16);
|
||||
return buf;
|
||||
}
|
||||
|
||||
bool IsIPAddrInNetwork(ACE_INET_Addr const& net, ACE_INET_Addr const& addr, ACE_INET_Addr const& subnetMask)
|
||||
{
|
||||
uint32 mask = subnetMask.get_ip_address();
|
||||
|
||||
Reference in new issue
Block a user