Replaced Common::Thread with a partial implementation of std::thread. (rvalue references are used if available, <thread> is used if possible) Eliminates the need to use dynamic memory allocation for threads, so it's impossible to forget to delete a thread or set a pointer to NULL. Enables use of type-safe thread functions, no need to cast to and from void*. I've made sure the code compiles in vs08 and tested the functionality of "StdThread.h" on Linux so I'm hoping everything will work :p. In the future "StdThread.h" can be removed (maybe when OS X ships with gcc 4.4 and vs2015 is released :p).

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6933 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Jordan Woyak 2011-01-27 20:47:58 +00:00
commit 2c05c49a04
29 changed files with 484 additions and 396 deletions

View file

@ -46,7 +46,7 @@ DSPConfigDialogLLE* m_ConfigFrame = NULL;
PLUGIN_GLOBALS* globals = NULL;
DSPInitialize g_dspInitialize;
Common::Thread *g_hDSPThread = NULL;
std::thread g_hDSPThread;
SoundStream *soundStream = NULL;
bool g_InitMixer = false;
@ -211,7 +211,7 @@ void *DllDebugger(void *_hParent, bool Show)
// Regular thread
THREAD_RETURN dsp_thread(void* lpParameter)
void dsp_thread()
{
while (bIsRunning)
{
@ -226,7 +226,6 @@ THREAD_RETURN dsp_thread(void* lpParameter)
}
// yield?
}
return 0;
}
void DSP_DebugBreak()
@ -276,7 +275,7 @@ void Initialize(void *init)
if (g_dspInitialize.bOnThread)
{
g_hDSPThread = new Common::Thread(dsp_thread, NULL);
g_hDSPThread = std::thread(dsp_thread);
}
#if defined(HAVE_WX) && HAVE_WX
@ -291,8 +290,7 @@ void DSP_StopSoundStream()
bIsRunning = false;
if (g_dspInitialize.bOnThread)
{
delete g_hDSPThread;
g_hDSPThread = NULL;
g_hDSPThread.join();
}
}