summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2011-01-31 08:19:27 +0000
committerJordan Woyak <jordan.woyak@gmail.com>2011-01-31 08:19:27 +0000
commit1de40588acd0bfa6d49e3d94fef2cbd6dc09f6e5 (patch)
tree93472097d7916eb4680f3b032286f729abdffd46
parent67a4ac0bf67d9299fb19575ccf5fc2034a8da9fd (diff)
Eliminate some trampoline functions.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7015 8ced0084-cf51-0410-be5f-012b33b47a6e
-rw-r--r--Source/Core/AudioCommon/Src/AOSoundStream.cpp8
-rw-r--r--Source/Core/AudioCommon/Src/AlsaSoundStream.cpp9
-rw-r--r--Source/Core/AudioCommon/Src/DSoundStream.cpp12
-rw-r--r--Source/Core/AudioCommon/Src/OpenALStream.cpp9
-rw-r--r--Source/Core/AudioCommon/Src/OpenALStream.h2
-rw-r--r--Source/Core/AudioCommon/Src/PulseAudioStream.cpp9
-rw-r--r--Source/Core/AudioCommon/Src/PulseAudioStream.h1
-rw-r--r--Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp1
-rw-r--r--Source/Core/Core/Src/HW/EXI_DeviceGecko.cpp9
-rw-r--r--Source/Core/Core/Src/HW/WiimoteReal/IONix.cpp2
-rw-r--r--Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp2
-rw-r--r--Source/Core/Core/Src/HW/WiimoteReal/IOdarwin.mm2
-rw-r--r--Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp5
-rw-r--r--Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.h3
-rw-r--r--Source/Core/DolphinWX/Src/NetPlay.cpp5
-rw-r--r--Source/Core/DolphinWX/Src/NetPlay.h9
-rw-r--r--Source/Core/DolphinWX/Src/NetPlayClient.cpp4
-rw-r--r--Source/Core/DolphinWX/Src/NetPlayServer.cpp4
-rw-r--r--Source/Core/InputCommon/Src/UDPWiimote.cpp11
-rw-r--r--Source/Core/InputCommon/Src/UDPWiimote.h4
20 files changed, 38 insertions, 73 deletions
diff --git a/Source/Core/AudioCommon/Src/AOSoundStream.cpp b/Source/Core/AudioCommon/Src/AOSoundStream.cpp
index a1bc0e0a76..c857856f1a 100644
--- a/Source/Core/AudioCommon/Src/AOSoundStream.cpp
+++ b/Source/Core/AudioCommon/Src/AOSoundStream.cpp
@@ -15,6 +15,7 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
+#include <functional>
#include <string.h>
#include "AOSoundStream.h"
@@ -54,18 +55,13 @@ void AOSound::SoundLoop()
}
}
-void soundThread(AOSound *aosound)
-{
- aosound->SoundLoop();
-}
-
bool AOSound::Start()
{
memset(realtimeBuffer, 0, sizeof(realtimeBuffer));
soundSyncEvent.Init();
- thread = std::thread(soundThread, this);
+ thread = std::thread(std::mem_fun(&AOSound::SoundLoop), this);
return true;
}
diff --git a/Source/Core/AudioCommon/Src/AlsaSoundStream.cpp b/Source/Core/AudioCommon/Src/AlsaSoundStream.cpp
index 5ad6e45390..76f13b6cb1 100644
--- a/Source/Core/AudioCommon/Src/AlsaSoundStream.cpp
+++ b/Source/Core/AudioCommon/Src/AlsaSoundStream.cpp
@@ -15,6 +15,8 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
+#include <functional>
+
#include "Common.h"
#include "Thread.h"
#include "AlsaSoundStream.h"
@@ -33,14 +35,9 @@ AlsaSound::~AlsaSound()
delete [] mix_buffer;
}
-static void ThreadTrampoline(AlsaSound* args)
-{
- args->SoundLoop();
-}
-
bool AlsaSound::Start()
{
- thread = std::thread(ThreadTrampoline, this);
+ thread = std::thread(std::mem_fun(&AlsaSound::SoundLoop), this);
thread_data = 0;
return true;
}
diff --git a/Source/Core/AudioCommon/Src/DSoundStream.cpp b/Source/Core/AudioCommon/Src/DSoundStream.cpp
index 4823c46732..206685f707 100644
--- a/Source/Core/AudioCommon/Src/DSoundStream.cpp
+++ b/Source/Core/AudioCommon/Src/DSoundStream.cpp
@@ -15,9 +15,12 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
-#include <windows.h>
#include <cmath>
+#include <functional>
+
+#include <windows.h>
#include <dxerr.h>
+
#include "AudioCommon.h"
#include "DSoundStream.h"
@@ -91,11 +94,6 @@ bool DSound::WriteDataToBuffer(DWORD dwOffset, // Our own write
}
// The audio thread.
-void soundThread(DSound* dsound)
-{
- dsound->SoundLoop();
-}
-
void DSound::SoundLoop()
{
currentPos = 0;
@@ -137,7 +135,7 @@ bool DSound::Start()
dsBuffer->Lock(0, bufferSize, (void* *)&p1, &num1, 0, 0, 0);
memset(p1, 0, num1);
dsBuffer->Unlock(p1, num1, 0, 0);
- thread = std::thread(soundThread, this);
+ thread = std::thread(std::mem_fun(&DSound::SoundLoop), this);
return true;
}
diff --git a/Source/Core/AudioCommon/Src/OpenALStream.cpp b/Source/Core/AudioCommon/Src/OpenALStream.cpp
index 908f1c0099..5d46763613 100644
--- a/Source/Core/AudioCommon/Src/OpenALStream.cpp
+++ b/Source/Core/AudioCommon/Src/OpenALStream.cpp
@@ -15,6 +15,8 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
+#include <functional>
+
#include "aldlist.h"
#include "OpenALStream.h"
@@ -44,7 +46,7 @@ bool OpenALStream::Start()
if (pContext)
{
alcMakeContextCurrent(pContext);
- thread = std::thread(OpenALStream::ThreadFunc, this);
+ thread = std::thread(std::mem_fun(&OpenALStream::SoundLoop), this);
bReturn = true;
}
else
@@ -121,11 +123,6 @@ void OpenALStream::Clear(bool mute)
}
}
-void OpenALStream::ThreadFunc(OpenALStream* alstream)
-{
- alstream->SoundLoop();
-}
-
void OpenALStream::SoundLoop()
{
ALenum err;
diff --git a/Source/Core/AudioCommon/Src/OpenALStream.h b/Source/Core/AudioCommon/Src/OpenALStream.h
index 7475fcfe83..b6e9253590 100644
--- a/Source/Core/AudioCommon/Src/OpenALStream.h
+++ b/Source/Core/AudioCommon/Src/OpenALStream.h
@@ -58,8 +58,6 @@ public:
virtual bool usesMixer() const { return true; }
virtual void Update();
- static void ThreadFunc(OpenALStream* args);
-
private:
std::thread thread;
Common::EventEx soundSyncEvent;
diff --git a/Source/Core/AudioCommon/Src/PulseAudioStream.cpp b/Source/Core/AudioCommon/Src/PulseAudioStream.cpp
index fd7aa31cfd..19d5d5c298 100644
--- a/Source/Core/AudioCommon/Src/PulseAudioStream.cpp
+++ b/Source/Core/AudioCommon/Src/PulseAudioStream.cpp
@@ -15,6 +15,8 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
+#include <functional>
+
#include "Common.h"
#include "Thread.h"
@@ -35,15 +37,10 @@ PulseAudio::~PulseAudio()
delete [] mix_buffer;
}
-void PulseAudio::ThreadTrampoline(PulseAudio* args)
-{
- args->SoundLoop();
-}
-
bool PulseAudio::Start()
{
thread_running = true;
- thread = std::thread(ThreadTrampoline, this);
+ thread = std::thread(std::mem_fun(&PulseAudio::SoundLoop), this);
return true;
}
diff --git a/Source/Core/AudioCommon/Src/PulseAudioStream.h b/Source/Core/AudioCommon/Src/PulseAudioStream.h
index 522e0ae6bb..f3a5a43e79 100644
--- a/Source/Core/AudioCommon/Src/PulseAudioStream.h
+++ b/Source/Core/AudioCommon/Src/PulseAudioStream.h
@@ -46,7 +46,6 @@ public:
private:
virtual void SoundLoop();
- static void ThreadTrampoline(PulseAudio* args);
bool PulseInit();
void PulseShutdown();
bool Write(const void *data, size_t bytes);
diff --git a/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp b/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp
index 3b217dea70..c2d4814756 100644
--- a/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp
+++ b/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp
@@ -158,7 +158,6 @@ void DSPLLE::Initialize(void *hWnd, bool bWii, bool bDSPThread)
if (m_bDSPThread)
{
-// m_hDSPThread = new Common::Thread(dsp_thread, (void *)this);
m_hDSPThread = std::thread(dsp_thread, this);
}
/*
diff --git a/Source/Core/Core/Src/HW/EXI_DeviceGecko.cpp b/Source/Core/Core/Src/HW/EXI_DeviceGecko.cpp
index a6d5df1d47..5b04e040f4 100644
--- a/Source/Core/Core/Src/HW/EXI_DeviceGecko.cpp
+++ b/Source/Core/Core/Src/HW/EXI_DeviceGecko.cpp
@@ -15,15 +15,12 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
+#include <functional>
+
#include "EXI_Device.h"
#include "EXI_DeviceGecko.h"
#include "../Core.h"
-void ClientThreadFunc(GeckoSockServer *arg)
-{
- arg->ClientThread();
-}
-
u16 GeckoSockServer::server_port;
int GeckoSockServer::client_count;
std::thread GeckoSockServer::connectionThread;
@@ -104,7 +101,7 @@ bool GeckoSockServer::GetAvailableSock(sf::SocketTCP &sock_to_fill)
recv_fifo = std::queue<u8>();
send_fifo = std::queue<u8>();
}
- clientThread = std::thread(ClientThreadFunc, this);
+ clientThread = std::thread(std::mem_fun(&GeckoSockServer::ClientThread), this);
client_count++;
waiting_socks.pop();
sock_filled = true;
diff --git a/Source/Core/Core/Src/HW/WiimoteReal/IONix.cpp b/Source/Core/Core/Src/HW/WiimoteReal/IONix.cpp
index 9fe3f9a9db..0e88c047dc 100644
--- a/Source/Core/Core/Src/HW/WiimoteReal/IONix.cpp
+++ b/Source/Core/Core/Src/HW/WiimoteReal/IONix.cpp
@@ -176,7 +176,7 @@ bool Wiimote::Connect()
// Set LEDs
SetLEDs(WIIMOTE_LED_1 << index);
- m_wiimote_thread = std::thread(StartThread, this);
+ m_wiimote_thread = std::thread(std::mem_fun(&Wiimote::ThreadFunc), this);
return true;
}
diff --git a/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp b/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp
index e08911fa97..013451cf4b 100644
--- a/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp
+++ b/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp
@@ -237,7 +237,7 @@ bool Wiimote::Connect()
// Set LEDs
SetLEDs(WIIMOTE_LED_1 << index);
- m_wiimote_thread = std::thread(StartThread, this);
+ m_wiimote_thread = std::thread(std::mem_fun(&Wiimote::ThreadFunc), this);
NOTICE_LOG(WIIMOTE, "Connected to wiimote %i.", index + 1);
diff --git a/Source/Core/Core/Src/HW/WiimoteReal/IOdarwin.mm b/Source/Core/Core/Src/HW/WiimoteReal/IOdarwin.mm
index 111b7b0177..4eef49dd22 100644
--- a/Source/Core/Core/Src/HW/WiimoteReal/IOdarwin.mm
+++ b/Source/Core/Core/Src/HW/WiimoteReal/IOdarwin.mm
@@ -198,7 +198,7 @@ bool Wiimote::Connect()
Handshake();
SetLEDs(WIIMOTE_LED_1 << index);
- m_wiimote_thread = std::thread(StartThread, this);
+ m_wiimote_thread = std::thread(std::mem_fun(&Wiimote::ThreadFunc), this);
[cbt release];
diff --git a/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp
index e7debdfb39..da2e0ea662 100644
--- a/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp
+++ b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp
@@ -297,11 +297,6 @@ bool Wiimote::SendRequest(unsigned char report_type, unsigned char* data, int le
return (IOWrite(buffer, length + 2) != 0);
}
-void Wiimote::StartThread(Wiimote *wiimote)
-{
- wiimote->ThreadFunc();
-}
-
void Wiimote::ThreadFunc()
{
char thname[] = "Wiimote # Thread";
diff --git a/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.h b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.h
index 7cbdacd5b7..429c71691a 100644
--- a/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.h
+++ b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.h
@@ -19,6 +19,8 @@
#ifndef WIIMOTE_REAL_H
#define WIIMOTE_REAL_H
+#include <functional>
+
#include "WiimoteRealBase.h"
#include "ChunkFile.h"
#include "Thread.h"
@@ -90,7 +92,6 @@ private:
void SetLEDs(int leds);
int IORead(unsigned char* buf);
int IOWrite(unsigned char* buf, int len);
- static void StartThread(Wiimote *wiimote);
void ThreadFunc();
bool m_connected;
diff --git a/Source/Core/DolphinWX/Src/NetPlay.cpp b/Source/Core/DolphinWX/Src/NetPlay.cpp
index 179ea3e3a1..8f37d4ffe9 100644
--- a/Source/Core/DolphinWX/Src/NetPlay.cpp
+++ b/Source/Core/DolphinWX/Src/NetPlay.cpp
@@ -38,11 +38,6 @@ extern CFrame* main_frame;
DEFINE_EVENT_TYPE(wxEVT_THREAD)
-void NetPlayThreadFunc(NetPlay* np)
-{
- np->Entry();
-}
-
// called from ---GUI--- thread
NetPlay::NetPlay()
: m_is_running(false), m_do_loop(true)
diff --git a/Source/Core/DolphinWX/Src/NetPlay.h b/Source/Core/DolphinWX/Src/NetPlay.h
index dcdd8bdd2e..fc0f01a401 100644
--- a/Source/Core/DolphinWX/Src/NetPlay.h
+++ b/Source/Core/DolphinWX/Src/NetPlay.h
@@ -10,6 +10,7 @@
#include "GCPadStatus.h"
+#include <functional>
#include <map>
#include <queue>
#include <sstream>
@@ -94,7 +95,7 @@ class NetPlay
public:
NetPlay();
virtual ~NetPlay();
- virtual void Entry() = 0;
+ //virtual void ThreadFunc() = 0;
bool is_connected;
@@ -163,15 +164,13 @@ private:
};
-void NetPlayThreadFunc(NetPlay* arg);
-
void NetPlay_Enable(NetPlay* const np);
void NetPlay_Disable();
class NetPlayServer : public NetPlay
{
public:
- void Entry();
+ void ThreadFunc();
NetPlayServer(const u16 port, const std::string& name, NetPlayDiag* const npd = NULL, const std::string& game = "");
~NetPlayServer();
@@ -220,7 +219,7 @@ private:
class NetPlayClient : public NetPlay
{
public:
- void Entry();
+ void ThreadFunc();
NetPlayClient(const std::string& address, const u16 port, const std::string& name, NetPlayDiag* const npd = NULL);
~NetPlayClient();
diff --git a/Source/Core/DolphinWX/Src/NetPlayClient.cpp b/Source/Core/DolphinWX/Src/NetPlayClient.cpp
index 639dee80ef..beeafc0e5b 100644
--- a/Source/Core/DolphinWX/Src/NetPlayClient.cpp
+++ b/Source/Core/DolphinWX/Src/NetPlayClient.cpp
@@ -72,7 +72,7 @@ NetPlayClient::NetPlayClient(const std::string& address, const u16 port, const s
is_connected = true;
m_selector.Add(m_socket);
- m_thread = std::thread(NetPlayThreadFunc, this);
+ m_thread = std::thread(std::mem_fun(&NetPlayClient::ThreadFunc), this);
}
}
else
@@ -237,7 +237,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
}
// called from ---NETPLAY--- thread
-void NetPlayClient::Entry()
+void NetPlayClient::ThreadFunc()
{
while (m_do_loop)
{
diff --git a/Source/Core/DolphinWX/Src/NetPlayServer.cpp b/Source/Core/DolphinWX/Src/NetPlayServer.cpp
index f6c6de5de9..e9905a9fe0 100644
--- a/Source/Core/DolphinWX/Src/NetPlayServer.cpp
+++ b/Source/Core/DolphinWX/Src/NetPlayServer.cpp
@@ -40,14 +40,14 @@ NetPlayServer::NetPlayServer(const u16 port, const std::string& name, NetPlayDia
is_connected = true;
m_selector.Add(m_socket);
- m_thread = std::thread(NetPlayThreadFunc, this);
+ m_thread = std::thread(std::mem_fun(&NetPlayServer::ThreadFunc), this);
}
else
is_connected = false;
}
// called from ---NETPLAY--- thread
-void NetPlayServer::Entry()
+void NetPlayServer::ThreadFunc()
{
while (m_do_loop)
{
diff --git a/Source/Core/InputCommon/Src/UDPWiimote.cpp b/Source/Core/InputCommon/Src/UDPWiimote.cpp
index 558e4d902d..d31b5ad047 100644
--- a/Source/Core/InputCommon/Src/UDPWiimote.cpp
+++ b/Source/Core/InputCommon/Src/UDPWiimote.cpp
@@ -39,11 +39,13 @@
#include "Thread.h"
#include "Timer.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <list>
+#include <functional>
struct UDPWiimote::_d
{
@@ -54,12 +56,7 @@ struct UDPWiimote::_d
sock_t bipv4_fd,bipv6_fd;
};
-int UDPWiimote::noinst=0;
-
-void UDPWiiThread(UDPWiimote* arg)
-{
- arg->mainThread();
-}
+int UDPWiimote::noinst = 0;
UDPWiimote::UDPWiimote(const char *_port, const char * name, int _index) :
port(_port), displayName(name),
@@ -135,7 +132,7 @@ UDPWiimote::UDPWiimote(const char *_port, const char * name, int _index) :
initBroadcastIPv4();
initBroadcastIPv6();
d->termLock.Enter();
- d->thread = std::thread(UDPWiiThread, this);
+ d->thread = std::thread(std::mem_fun(&UDPWiimote::mainThread), this);
d->termLock.Leave();
return;
}
diff --git a/Source/Core/InputCommon/Src/UDPWiimote.h b/Source/Core/InputCommon/Src/UDPWiimote.h
index 02fa4f66bc..1be83dbf74 100644
--- a/Source/Core/InputCommon/Src/UDPWiimote.h
+++ b/Source/Core/InputCommon/Src/UDPWiimote.h
@@ -21,7 +21,6 @@
class UDPWiimote
{
- friend void UDPWiiThread(UDPWiimote* arg);
public:
UDPWiimote(const char * port, const char * name, int index);
virtual ~UDPWiimote();
@@ -33,10 +32,11 @@ public:
int getErrNo() {return err;};
const char * getPort();
void changeName(const char * name);
+
+ void mainThread();
private:
std::string port,displayName;
int pharsePacket(u8 * data, size_t size);
- void mainThread();
struct _d; //using pimpl because Winsock2.h doesen't have include guards -_-
_d *d;
double x,y,z;