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
parent 0371f15c23
commit 2c05c49a04
29 changed files with 484 additions and 396 deletions

View File

@ -38,10 +38,9 @@ extern CFrame* main_frame;
DEFINE_EVENT_TYPE(wxEVT_THREAD)
THREAD_RETURN NetPlayThreadFunc(void* arg)
void NetPlayThreadFunc(NetPlay* np)
{
((NetPlay*)arg)->Entry();
return 0;
np->Entry();
}
// called from ---GUI--- thread

View File

@ -76,8 +76,6 @@ enum
CON_ERR_VERSION_MISMATCH
};
THREAD_RETURN NetPlayThreadFunc(void* arg);
// something like this should be in Common stuff
class CritLocker
{
@ -116,7 +114,6 @@ public:
u8 GetPadNum(u8 numPAD);
protected:
//NetPlay(Common::ThreadFunc entry, void* arg) : m_thread(entry, arg) {}
//void GetBufferedPad(const u8 pad_nb, NetPad* const netvalues);
void ClearBuffers();
void UpdateGUI();
@ -149,7 +146,7 @@ protected:
NetPlayDiag* m_dialog;
sf::SocketTCP m_socket;
Common::Thread* m_thread;
std::thread m_thread;
sf::Selector<sf::SocketTCP> m_selector;
std::string m_selected_game;
@ -166,6 +163,8 @@ private:
};
void NetPlayThreadFunc(NetPlay* arg);
void NetPlay_Enable(NetPlay* const np);
void NetPlay_Disable();

View File

@ -7,8 +7,7 @@ NetPlayClient::~NetPlayClient()
if (is_connected)
{
m_do_loop = false;
m_thread->WaitForDeath();
delete m_thread;
m_thread.join();
}
}
@ -73,7 +72,7 @@ NetPlayClient::NetPlayClient(const std::string& address, const u16 port, const s
is_connected = true;
m_selector.Add(m_socket);
m_thread = new Common::Thread(NetPlayThreadFunc, this);
m_thread = std::thread(NetPlayThreadFunc, this);
}
}
else

View File

@ -7,8 +7,7 @@ NetPlayServer::~NetPlayServer()
if (is_connected)
{
m_do_loop = false;
m_thread->WaitForDeath();
delete m_thread;
m_thread.join();
}
}
@ -41,7 +40,7 @@ NetPlayServer::NetPlayServer(const u16 port, const std::string& name, NetPlayDia
is_connected = true;
m_selector.Add(m_socket);
m_thread = new Common::Thread(NetPlayThreadFunc, this);
m_thread = std::thread(NetPlayThreadFunc, this);
}
else
is_connected = false;