Replaced Common::CriticalSection with a std::mutex implementation. 64bit Windows builds now use SRWLocks and ConditionVariables(requires Vista/7, x64 builds will no longer work on Windows XP x64). Tell me if you hate that. Removed Common::EventEx. Common::Event now uses a std::condition_variable impl.(using ConditionVariables on Windows x64, Events on x86, or posix condition variables elsewhere). I experience slight speed improvements with these changes.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7294 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Jordan Woyak
2011-03-05 06:11:26 +00:00
parent a037ff2358
commit 423018f811
56 changed files with 918 additions and 835 deletions

View File

@ -121,8 +121,6 @@ CCodeWindow::CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter
sizerLeft->Fit(this);
sizerBig->Fit(this);
sync_event.Init();
}
wxMenuBar *CCodeWindow::GetMenuBar()

View File

@ -354,8 +354,6 @@ CFrame::CFrame(wxFrame* parent,
bFloatWindow[i] = false;
#ifdef __WXGTK__
panic_event.Init();
keystate_event.Init();
bKeyStateResult = false;
#endif
@ -492,11 +490,6 @@ CFrame::~CFrame()
ClosePages();
#ifdef __WXGTK__
panic_event.Shutdown();
keystate_event.Shutdown();
#endif
delete m_Mgr;
}

View File

@ -278,9 +278,8 @@ void GamepadPage::ClearAll(wxCommandEvent&)
// no point in using the real ControllerInterface i guess
ControllerInterface face;
m_plugin.controls_crit.Enter(); // enter
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
controller->UpdateReferences(face);
m_plugin.controls_crit.Leave(); // leave
UpdateGUI();
}
@ -289,9 +288,8 @@ void GamepadPage::LoadDefaults(wxCommandEvent&)
{
controller->LoadDefaults(g_controller_interface);
m_plugin.controls_crit.Enter(); // enter
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
controller->UpdateReferences(g_controller_interface);
m_plugin.controls_crit.Leave(); // leave
UpdateGUI();
}
@ -300,9 +298,8 @@ void ControlDialog::SetControl(wxCommandEvent&)
{
control_reference->expression = STR_FROM_WXSTR(textctrl->GetValue());
m_plugin.controls_crit.Enter(); // enter
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
m_plugin.controls_crit.Leave(); // leave
UpdateGUI();
}
@ -318,9 +315,8 @@ void GamepadPage::SetDevice(wxCommandEvent&)
controller->UpdateDefaultDevice();
// update references
m_plugin.controls_crit.Enter(); // enter
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
controller->UpdateReferences(g_controller_interface);
m_plugin.controls_crit.Leave(); // leave
}
void ControlDialog::SetDevice(wxCommandEvent&)
@ -338,9 +334,8 @@ void ControlDialog::ClearControl(wxCommandEvent&)
{
control_reference->expression.clear();
m_plugin.controls_crit.Enter(); // enter
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
m_plugin.controls_crit.Leave(); // leave
UpdateGUI();
}
@ -363,9 +358,8 @@ void ControlDialog::SetSelectedControl(wxCommandEvent&)
control_reference->expression = STR_FROM_WXSTR(expr);
m_plugin.controls_crit.Enter(); // enter
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
m_plugin.controls_crit.Leave(); // leave
UpdateGUI();
}
@ -395,25 +389,22 @@ void ControlDialog::AppendControl(wxCommandEvent& event)
control_reference->expression = STR_FROM_WXSTR(expr);
m_plugin.controls_crit.Enter(); // enter
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
m_plugin.controls_crit.Leave(); // leave
UpdateGUI();
}
void GamepadPage::AdjustSetting(wxCommandEvent& event)
{
m_plugin.controls_crit.Enter(); // enter / prolly fine not being here
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
((PadSetting*)((wxControl*)event.GetEventObject())->GetClientData())->UpdateValue();
m_plugin.controls_crit.Leave(); // leave
}
void GamepadPage::AdjustControlOption(wxCommandEvent&)
{
m_plugin.controls_crit.Enter(); // enter / prolly fine not being here
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
m_control_dialog->control_reference->range = (ControlState)(m_control_dialog->range_slider->GetValue()) / SLIDER_TICK_COUNT;
m_plugin.controls_crit.Leave(); // leave
}
void GamepadPage::ConfigControl(wxCommandEvent& event)
@ -432,9 +423,8 @@ void GamepadPage::ClearControl(wxCommandEvent& event)
btn->control_reference->expression.clear();
btn->control_reference->range = 1.0f;
m_plugin.controls_crit.Enter(); // enter
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
controller->UpdateReferences(g_controller_interface);
m_plugin.controls_crit.Leave(); // leave
// update changes
UpdateGUI();
@ -453,9 +443,8 @@ void ControlDialog::DetectControl(wxCommandEvent& event)
// apparently, this makes the "waiting" text work on Linux
wxTheApp->Yield();
m_plugin.controls_crit.Enter(); // enter
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
ControllerInterface::Device::Control* const ctrl = control_reference->Detect(DETECT_WAIT_TIME, dev);
m_plugin.controls_crit.Leave(); // leave
// if we got input, select it in the list
if (ctrl)
@ -478,7 +467,7 @@ void GamepadPage::DetectControl(wxCommandEvent& event)
// apparently, this makes the "waiting" text work on Linux
wxTheApp->Yield();
m_plugin.controls_crit.Enter(); // enter
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
ControllerInterface::Device::Control* const ctrl = btn->control_reference->Detect(DETECT_WAIT_TIME, dev);
// if we got input, update expression and reference
@ -488,8 +477,6 @@ void GamepadPage::DetectControl(wxCommandEvent& event)
g_controller_interface.UpdateReference(btn->control_reference, controller->default_device);
}
m_plugin.controls_crit.Leave(); // leave
btn->SetLabel(WXSTR_FROM_STR(btn->control_reference->expression));
}
}
@ -597,10 +584,9 @@ void GamepadPage::LoadProfile(wxCommandEvent&)
IniFile inifile;
inifile.Load(fname);
m_plugin.controls_crit.Enter();
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
controller->LoadConfig(inifile.GetOrCreateSection("Profile"));
controller->UpdateReferences(g_controller_interface);
m_plugin.controls_crit.Leave();
UpdateGUI();
}
@ -662,7 +648,7 @@ void InputConfigDialog::UpdateDeviceComboBox()
void GamepadPage::RefreshDevices(wxCommandEvent&)
{
m_plugin.controls_crit.Enter(); // enter
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
// refresh devices
g_controller_interface.Shutdown();
@ -673,8 +659,6 @@ void GamepadPage::RefreshDevices(wxCommandEvent&)
// update device cbox
m_config_dialog->UpdateDeviceComboBox();
m_plugin.controls_crit.Leave(); // leave
}
ControlGroupBox::~ControlGroupBox()

View File

@ -22,8 +22,10 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
wxFont small_font(6, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
g_controller_interface.UpdateInput();
// don't want game thread updating input when we are using it here
if (false == g_controller_interface.update_lock.TryEnter())
std::unique_lock<std::mutex> lk(g_controller_interface.update_lock, std::try_to_lock);
if (!lk.owns_lock())
return;
GamepadPage* const current_page = (GamepadPage*)m_pad_notebook->GetPage(m_pad_notebook->GetSelection());
@ -344,6 +346,4 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
(*g)->static_bitmap->SetBitmap(bitmap);
}
}
g_controller_interface.update_lock.Leave();
}

View File

@ -42,7 +42,6 @@ CLogWindow::CLogWindow(CFrame *parent, wxWindowID id, const wxPoint& pos,
, x(0), y(0), winpos(0)
, Parent(parent) , m_LogAccess(true)
, m_Log(NULL), m_cmdline(NULL), m_FontChoice(NULL)
, m_LogSection(1)
, m_SJISConv(wxT(""))
{
#ifdef _WIN32
@ -212,11 +211,12 @@ void CLogWindow::OnClear(wxCommandEvent& WXUNUSED (event))
{
m_Log->Clear();
m_LogSection.Enter();
{
std::lock_guard<std::mutex> lk(m_LogSection);
int msgQueueSize = (int)msgQueue.size();
for (int i = 0; i < msgQueueSize; i++)
msgQueue.pop();
m_LogSection.Leave();
}
m_LogManager->getConsoleListener()->ClearScreen();
}
@ -308,7 +308,8 @@ void CLogWindow::UpdateLog()
m_LogTimer->Stop();
m_LogSection.Enter();
{
std::lock_guard<std::mutex> lk(m_LogSection);
int msgQueueSize = (int)msgQueue.size();
for (int i = 0; i < msgQueueSize; i++)
{
@ -348,16 +349,16 @@ void CLogWindow::UpdateLog()
}
msgQueue.pop();
}
m_LogSection.Leave();
} // unlock log
m_LogTimer->Start(UPDATETIME);
}
void CLogWindow::Log(LogTypes::LOG_LEVELS level, const char *text)
{
m_LogSection.Enter();
std::lock_guard<std::mutex> lk(m_LogSection);
if (msgQueue.size() >= 100)
msgQueue.pop();
msgQueue.push(std::pair<u8, wxString>((u8)level, wxString(text, m_SJISConv)));
m_LogSection.Leave();
}

View File

@ -72,7 +72,7 @@ private:
wxChoice *m_FontChoice;
wxCheckBox *m_WrapLine;
Common::CriticalSection m_LogSection;
std::mutex m_LogSection;
wxCSConv m_SJISConv;