#include "marshaller.h" #include #include #include #include "rbx/Debug.h" #include "rbx/Profiler.h" __declspec(thread) static void* g_syncEvent; // per thread extern void dprintf( const char* fmt, ... ); void* Marshaller::getSyncEvent() { if( !g_syncEvent ) { g_syncEvent = CreateEvent(0, 0, 0, 0); RBX::mutex::scoped_lock lck(cleanupMutex); cleanup.push_back(&g_syncEvent); } return g_syncEvent; } Marshaller::Marshaller() { mainThread = GetCurrentThreadId(); hmainThread = OpenThread(THREAD_ALL_ACCESS, FALSE, mainThread); RBXASSERT(hmainThread); dprintf( "Marshaller started on thread %I64x (%I64d)\n", mainThread, mainThread ); } Marshaller::~Marshaller() { CloseHandle(hmainThread); for( int j=0, e=(int)cleanup.size(); jsuccess = true; } catch (const std::exception& e) { if (desc.result) { desc.result->success = false; desc.result->except = e.what(); } else { // We've got nothing to report to, just dump it somewhere // TODO: replace with debugging stuff dprintf("%s\n", e.what()); RBXASSERT(0); // haha, exceptions suck } } if (desc.result && desc.result->sync) { SetEvent(desc.result->sync); } return true; }