Skip to content

Commit

Permalink
Replaced Threading and SFMT access related code with std::thread and …
Browse files Browse the repository at this point in the history
…boost TSS

Note: The remote access thread is currently broken due to unknown ACE fail (will be replaced at some point anyways..)
  • Loading branch information
leak committed Jun 21, 2014
1 parent 55dee85 commit 33dc72a
Show file tree
Hide file tree
Showing 16 changed files with 138 additions and 565 deletions.
87 changes: 46 additions & 41 deletions dep/SFMT/SFMT.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,13 @@ __m128i const &c, __m128i const &d, __m128i const &mask) {
return z2;
}

namespace boost {
template <typename T> class thread_specific_ptr;
}

// Class for SFMT generator
class SFMTRand { // Encapsulate random number generator
friend class ACE_TSS<SFMTRand>;
friend class boost::thread_specific_ptr<SFMTRand>;

public:
SFMTRand()
Expand Down Expand Up @@ -243,6 +247,47 @@ class SFMTRand { // Encapsulate random number gener
y = ((uint32_t*)state)[ix++];
return y;
}

void* operator new(size_t size, std::nothrow_t const&)
{
return _mm_malloc(size, 16);
}

void operator delete(void* ptr, std::nothrow_t const&)
{
_mm_free(ptr);
}

void* operator new(size_t size)
{
return _mm_malloc(size, 16);
}

void operator delete(void* ptr)
{
_mm_free(ptr);
}

void* operator new[](size_t size, std::nothrow_t const&)
{
return _mm_malloc(size, 16);
}

void operator delete[](void* ptr, std::nothrow_t const&)
{
_mm_free(ptr);
}

void* operator new[](size_t size)
{
return _mm_malloc(size, 16);
}

void operator delete[](void* ptr)
{
_mm_free(ptr);
}

private:
void Init2() // Various initializations and period certification
{
Expand Down Expand Up @@ -307,46 +352,6 @@ class SFMTRand { // Encapsulate random number gener
ix = 0;
}

void* operator new(size_t size, std::nothrow_t const&)
{
return _mm_malloc(size, 16);
}

void operator delete(void* ptr, std::nothrow_t const&)
{
_mm_free(ptr);
}

void* operator new(size_t size)
{
return _mm_malloc(size, 16);
}

void operator delete(void* ptr)
{
_mm_free(ptr);
}

void* operator new[](size_t size, std::nothrow_t const&)
{
return _mm_malloc(size, 16);
}

void operator delete[](void* ptr, std::nothrow_t const&)
{
_mm_free(ptr);
}

void* operator new[](size_t size)
{
return _mm_malloc(size, 16);
}

void operator delete[](void* ptr)
{
_mm_free(ptr);
}

__m128i mask; // AND mask
__m128i state[SFMT_N]; // State vector for SFMT generator
uint32_t ix; // Index into state array
Expand Down
3 changes: 0 additions & 3 deletions src/server/shared/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
#include "Debugging/Errors.h"

#include "Threading/LockedQueue.h"
#include "Threading/Threading.h"

#if PLATFORM == PLATFORM_WINDOWS
# include <ws2tcpip.h>
Expand Down Expand Up @@ -114,8 +113,6 @@

inline float finiteAlways(float f) { return finite(f) ? f : 0.0f; }

#define atol(a) strtoul( a, NULL, 10)

#define STRINGIZE(a) #a

enum TimeConstants
Expand Down
27 changes: 1 addition & 26 deletions src/server/shared/Database/MySQLThreading.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,6 @@
class MySQL
{
public:
/*! Create a thread on the MySQL server to mirrior the calling thread,
initializes thread-specific variables and allows thread-specific
operations without concurrence from other threads.
This should only be called if multiple core threads are running
on the same MySQL connection. Seperate MySQL connections implicitly
create a mirror thread.
*/
static void Thread_Init()
{
mysql_thread_init();
TC_LOG_WARN("sql.sql", "Core thread with ID [" UI64FMTD "] initializing MySQL thread.",
(uint64)ACE_Based::Thread::currentId());
}

/*! Shuts down MySQL thread and frees resources, should only be called
when we terminate. MySQL threads and connections are not configurable
during runtime.
*/
static void Thread_End()
{
mysql_thread_end();
TC_LOG_WARN("sql.sql", "Core thread with ID [" UI64FMTD "] shutting down MySQL thread.",
(uint64)ACE_Based::Thread::currentId());
}

static void Library_Init()
{
mysql_library_init(-1, NULL, NULL);
Expand All @@ -59,4 +34,4 @@ class MySQL
}
};

#endif
#endif
Loading

0 comments on commit 33dc72a

Please sign in to comment.