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
// 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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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);

View File

@ -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);
}
/*

View File

@ -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;

View File

@ -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;
}

View File

@ -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);

View File

@ -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];

View File

@ -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";

View File

@ -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;

View File

@ -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)

View File

@ -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();

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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;
}

View File

@ -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;