Eliminate some trampoline functions.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7015 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Jordan Woyak
2011-01-31 08:19:27 +00:00
parent 67a4ac0bf6
commit 1de40588ac
20 changed files with 38 additions and 73 deletions

View File

@ -15,6 +15,7 @@
// Official SVN repository and contact information can be found at // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#include <functional>
#include <string.h> #include <string.h>
#include "AOSoundStream.h" #include "AOSoundStream.h"
@ -54,18 +55,13 @@ void AOSound::SoundLoop()
} }
} }
void soundThread(AOSound *aosound)
{
aosound->SoundLoop();
}
bool AOSound::Start() bool AOSound::Start()
{ {
memset(realtimeBuffer, 0, sizeof(realtimeBuffer)); memset(realtimeBuffer, 0, sizeof(realtimeBuffer));
soundSyncEvent.Init(); soundSyncEvent.Init();
thread = std::thread(soundThread, this); thread = std::thread(std::mem_fun(&AOSound::SoundLoop), this);
return true; return true;
} }

View File

@ -15,6 +15,8 @@
// Official SVN repository and contact information can be found at // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#include <functional>
#include "Common.h" #include "Common.h"
#include "Thread.h" #include "Thread.h"
#include "AlsaSoundStream.h" #include "AlsaSoundStream.h"
@ -33,14 +35,9 @@ AlsaSound::~AlsaSound()
delete [] mix_buffer; delete [] mix_buffer;
} }
static void ThreadTrampoline(AlsaSound* args)
{
args->SoundLoop();
}
bool AlsaSound::Start() bool AlsaSound::Start()
{ {
thread = std::thread(ThreadTrampoline, this); thread = std::thread(std::mem_fun(&AlsaSound::SoundLoop), this);
thread_data = 0; thread_data = 0;
return true; return true;
} }

View File

@ -15,9 +15,12 @@
// Official SVN repository and contact information can be found at // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#include <windows.h>
#include <cmath> #include <cmath>
#include <functional>
#include <windows.h>
#include <dxerr.h> #include <dxerr.h>
#include "AudioCommon.h" #include "AudioCommon.h"
#include "DSoundStream.h" #include "DSoundStream.h"
@ -91,11 +94,6 @@ bool DSound::WriteDataToBuffer(DWORD dwOffset, // Our own write
} }
// The audio thread. // The audio thread.
void soundThread(DSound* dsound)
{
dsound->SoundLoop();
}
void DSound::SoundLoop() void DSound::SoundLoop()
{ {
currentPos = 0; currentPos = 0;
@ -137,7 +135,7 @@ bool DSound::Start()
dsBuffer->Lock(0, bufferSize, (void* *)&p1, &num1, 0, 0, 0); dsBuffer->Lock(0, bufferSize, (void* *)&p1, &num1, 0, 0, 0);
memset(p1, 0, num1); memset(p1, 0, num1);
dsBuffer->Unlock(p1, num1, 0, 0); dsBuffer->Unlock(p1, num1, 0, 0);
thread = std::thread(soundThread, this); thread = std::thread(std::mem_fun(&DSound::SoundLoop), this);
return true; return true;
} }

View File

@ -15,6 +15,8 @@
// Official SVN repository and contact information can be found at // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#include <functional>
#include "aldlist.h" #include "aldlist.h"
#include "OpenALStream.h" #include "OpenALStream.h"
@ -44,7 +46,7 @@ bool OpenALStream::Start()
if (pContext) if (pContext)
{ {
alcMakeContextCurrent(pContext); alcMakeContextCurrent(pContext);
thread = std::thread(OpenALStream::ThreadFunc, this); thread = std::thread(std::mem_fun(&OpenALStream::SoundLoop), this);
bReturn = true; bReturn = true;
} }
else else
@ -121,11 +123,6 @@ void OpenALStream::Clear(bool mute)
} }
} }
void OpenALStream::ThreadFunc(OpenALStream* alstream)
{
alstream->SoundLoop();
}
void OpenALStream::SoundLoop() void OpenALStream::SoundLoop()
{ {
ALenum err; ALenum err;

View File

@ -58,8 +58,6 @@ public:
virtual bool usesMixer() const { return true; } virtual bool usesMixer() const { return true; }
virtual void Update(); virtual void Update();
static void ThreadFunc(OpenALStream* args);
private: private:
std::thread thread; std::thread thread;
Common::EventEx soundSyncEvent; Common::EventEx soundSyncEvent;

View File

@ -15,6 +15,8 @@
// Official SVN repository and contact information can be found at // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#include <functional>
#include "Common.h" #include "Common.h"
#include "Thread.h" #include "Thread.h"
@ -35,15 +37,10 @@ PulseAudio::~PulseAudio()
delete [] mix_buffer; delete [] mix_buffer;
} }
void PulseAudio::ThreadTrampoline(PulseAudio* args)
{
args->SoundLoop();
}
bool PulseAudio::Start() bool PulseAudio::Start()
{ {
thread_running = true; thread_running = true;
thread = std::thread(ThreadTrampoline, this); thread = std::thread(std::mem_fun(&PulseAudio::SoundLoop), this);
return true; return true;
} }

View File

@ -46,7 +46,6 @@ public:
private: private:
virtual void SoundLoop(); virtual void SoundLoop();
static void ThreadTrampoline(PulseAudio* args);
bool PulseInit(); bool PulseInit();
void PulseShutdown(); void PulseShutdown();
bool Write(const void *data, size_t bytes); bool Write(const void *data, size_t bytes);

View File

@ -158,7 +158,6 @@ void DSPLLE::Initialize(void *hWnd, bool bWii, bool bDSPThread)
if (m_bDSPThread) if (m_bDSPThread)
{ {
// m_hDSPThread = new Common::Thread(dsp_thread, (void *)this);
m_hDSPThread = std::thread(dsp_thread, this); m_hDSPThread = std::thread(dsp_thread, this);
} }
/* /*

View File

@ -15,15 +15,12 @@
// Official SVN repository and contact information can be found at // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#include <functional>
#include "EXI_Device.h" #include "EXI_Device.h"
#include "EXI_DeviceGecko.h" #include "EXI_DeviceGecko.h"
#include "../Core.h" #include "../Core.h"
void ClientThreadFunc(GeckoSockServer *arg)
{
arg->ClientThread();
}
u16 GeckoSockServer::server_port; u16 GeckoSockServer::server_port;
int GeckoSockServer::client_count; int GeckoSockServer::client_count;
std::thread GeckoSockServer::connectionThread; std::thread GeckoSockServer::connectionThread;
@ -104,7 +101,7 @@ bool GeckoSockServer::GetAvailableSock(sf::SocketTCP &sock_to_fill)
recv_fifo = std::queue<u8>(); recv_fifo = std::queue<u8>();
send_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++; client_count++;
waiting_socks.pop(); waiting_socks.pop();
sock_filled = true; sock_filled = true;

View File

@ -176,7 +176,7 @@ bool Wiimote::Connect()
// Set LEDs // Set LEDs
SetLEDs(WIIMOTE_LED_1 << index); 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; return true;
} }

View File

@ -237,7 +237,7 @@ bool Wiimote::Connect()
// Set LEDs // Set LEDs
SetLEDs(WIIMOTE_LED_1 << index); 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); NOTICE_LOG(WIIMOTE, "Connected to wiimote %i.", index + 1);

View File

@ -198,7 +198,7 @@ bool Wiimote::Connect()
Handshake(); Handshake();
SetLEDs(WIIMOTE_LED_1 << index); 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]; [cbt release];

View File

@ -297,11 +297,6 @@ bool Wiimote::SendRequest(unsigned char report_type, unsigned char* data, int le
return (IOWrite(buffer, length + 2) != 0); return (IOWrite(buffer, length + 2) != 0);
} }
void Wiimote::StartThread(Wiimote *wiimote)
{
wiimote->ThreadFunc();
}
void Wiimote::ThreadFunc() void Wiimote::ThreadFunc()
{ {
char thname[] = "Wiimote # Thread"; char thname[] = "Wiimote # Thread";

View File

@ -19,6 +19,8 @@
#ifndef WIIMOTE_REAL_H #ifndef WIIMOTE_REAL_H
#define WIIMOTE_REAL_H #define WIIMOTE_REAL_H
#include <functional>
#include "WiimoteRealBase.h" #include "WiimoteRealBase.h"
#include "ChunkFile.h" #include "ChunkFile.h"
#include "Thread.h" #include "Thread.h"
@ -90,7 +92,6 @@ private:
void SetLEDs(int leds); void SetLEDs(int leds);
int IORead(unsigned char* buf); int IORead(unsigned char* buf);
int IOWrite(unsigned char* buf, int len); int IOWrite(unsigned char* buf, int len);
static void StartThread(Wiimote *wiimote);
void ThreadFunc(); void ThreadFunc();
bool m_connected; bool m_connected;

View File

@ -38,11 +38,6 @@ extern CFrame* main_frame;
DEFINE_EVENT_TYPE(wxEVT_THREAD) DEFINE_EVENT_TYPE(wxEVT_THREAD)
void NetPlayThreadFunc(NetPlay* np)
{
np->Entry();
}
// called from ---GUI--- thread // called from ---GUI--- thread
NetPlay::NetPlay() NetPlay::NetPlay()
: m_is_running(false), m_do_loop(true) : m_is_running(false), m_do_loop(true)

View File

@ -10,6 +10,7 @@
#include "GCPadStatus.h" #include "GCPadStatus.h"
#include <functional>
#include <map> #include <map>
#include <queue> #include <queue>
#include <sstream> #include <sstream>
@ -94,7 +95,7 @@ class NetPlay
public: public:
NetPlay(); NetPlay();
virtual ~NetPlay(); virtual ~NetPlay();
virtual void Entry() = 0; //virtual void ThreadFunc() = 0;
bool is_connected; bool is_connected;
@ -163,15 +164,13 @@ private:
}; };
void NetPlayThreadFunc(NetPlay* arg);
void NetPlay_Enable(NetPlay* const np); void NetPlay_Enable(NetPlay* const np);
void NetPlay_Disable(); void NetPlay_Disable();
class NetPlayServer : public NetPlay class NetPlayServer : public NetPlay
{ {
public: public:
void Entry(); void ThreadFunc();
NetPlayServer(const u16 port, const std::string& name, NetPlayDiag* const npd = NULL, const std::string& game = ""); NetPlayServer(const u16 port, const std::string& name, NetPlayDiag* const npd = NULL, const std::string& game = "");
~NetPlayServer(); ~NetPlayServer();
@ -220,7 +219,7 @@ private:
class NetPlayClient : public NetPlay class NetPlayClient : public NetPlay
{ {
public: public:
void Entry(); void ThreadFunc();
NetPlayClient(const std::string& address, const u16 port, const std::string& name, NetPlayDiag* const npd = NULL); NetPlayClient(const std::string& address, const u16 port, const std::string& name, NetPlayDiag* const npd = NULL);
~NetPlayClient(); ~NetPlayClient();

View File

@ -72,7 +72,7 @@ NetPlayClient::NetPlayClient(const std::string& address, const u16 port, const s
is_connected = true; is_connected = true;
m_selector.Add(m_socket); m_selector.Add(m_socket);
m_thread = std::thread(NetPlayThreadFunc, this); m_thread = std::thread(std::mem_fun(&NetPlayClient::ThreadFunc), this);
} }
} }
else else
@ -237,7 +237,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
} }
// called from ---NETPLAY--- thread // called from ---NETPLAY--- thread
void NetPlayClient::Entry() void NetPlayClient::ThreadFunc()
{ {
while (m_do_loop) while (m_do_loop)
{ {

View File

@ -40,14 +40,14 @@ NetPlayServer::NetPlayServer(const u16 port, const std::string& name, NetPlayDia
is_connected = true; is_connected = true;
m_selector.Add(m_socket); m_selector.Add(m_socket);
m_thread = std::thread(NetPlayThreadFunc, this); m_thread = std::thread(std::mem_fun(&NetPlayServer::ThreadFunc), this);
} }
else else
is_connected = false; is_connected = false;
} }
// called from ---NETPLAY--- thread // called from ---NETPLAY--- thread
void NetPlayServer::Entry() void NetPlayServer::ThreadFunc()
{ {
while (m_do_loop) while (m_do_loop)
{ {

View File

@ -39,11 +39,13 @@
#include "Thread.h" #include "Thread.h"
#include "Timer.h" #include "Timer.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <list> #include <list>
#include <functional>
struct UDPWiimote::_d struct UDPWiimote::_d
{ {
@ -54,12 +56,7 @@ struct UDPWiimote::_d
sock_t bipv4_fd,bipv6_fd; sock_t bipv4_fd,bipv6_fd;
}; };
int UDPWiimote::noinst=0; int UDPWiimote::noinst = 0;
void UDPWiiThread(UDPWiimote* arg)
{
arg->mainThread();
}
UDPWiimote::UDPWiimote(const char *_port, const char * name, int _index) : UDPWiimote::UDPWiimote(const char *_port, const char * name, int _index) :
port(_port), displayName(name), port(_port), displayName(name),
@ -135,7 +132,7 @@ UDPWiimote::UDPWiimote(const char *_port, const char * name, int _index) :
initBroadcastIPv4(); initBroadcastIPv4();
initBroadcastIPv6(); initBroadcastIPv6();
d->termLock.Enter(); d->termLock.Enter();
d->thread = std::thread(UDPWiiThread, this); d->thread = std::thread(std::mem_fun(&UDPWiimote::mainThread), this);
d->termLock.Leave(); d->termLock.Leave();
return; return;
} }

View File

@ -21,7 +21,6 @@
class UDPWiimote class UDPWiimote
{ {
friend void UDPWiiThread(UDPWiimote* arg);
public: public:
UDPWiimote(const char * port, const char * name, int index); UDPWiimote(const char * port, const char * name, int index);
virtual ~UDPWiimote(); virtual ~UDPWiimote();
@ -33,10 +32,11 @@ public:
int getErrNo() {return err;}; int getErrNo() {return err;};
const char * getPort(); const char * getPort();
void changeName(const char * name); void changeName(const char * name);
void mainThread();
private: private:
std::string port,displayName; std::string port,displayName;
int pharsePacket(u8 * data, size_t size); int pharsePacket(u8 * data, size_t size);
void mainThread();
struct _d; //using pimpl because Winsock2.h doesen't have include guards -_- struct _d; //using pimpl because Winsock2.h doesen't have include guards -_-
_d *d; _d *d;
double x,y,z; double x,y,z;