mirror of https://github.com/axmolengine/axmol.git
removed use of std::mutex. Now using lock-free concurrent_queue
This commit is contained in:
parent
bb7351ad46
commit
77c00bc77f
|
@ -33,6 +33,7 @@ THE SOFTWARE.
|
||||||
#include "deprecated/CCNotificationCenter.h"
|
#include "deprecated/CCNotificationCenter.h"
|
||||||
|
|
||||||
using namespace Platform;
|
using namespace Platform;
|
||||||
|
using namespace Concurrency;
|
||||||
using namespace Windows::Foundation;
|
using namespace Windows::Foundation;
|
||||||
using namespace Windows::Foundation::Collections;
|
using namespace Windows::Foundation::Collections;
|
||||||
using namespace Windows::Graphics::Display;
|
using namespace Windows::Graphics::Display;
|
||||||
|
@ -454,33 +455,27 @@ void GLViewImpl::setScissorInPoints(float x , float y , float w , float h)
|
||||||
|
|
||||||
void GLViewImpl::QueueBackKeyPress()
|
void GLViewImpl::QueueBackKeyPress()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(mMutex);
|
|
||||||
std::shared_ptr<BackButtonEvent> e(new BackButtonEvent());
|
std::shared_ptr<BackButtonEvent> e(new BackButtonEvent());
|
||||||
mInputEvents.push(e);
|
mInputEvents.push(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLViewImpl::QueuePointerEvent(PointerEventType type, PointerEventArgs^ args)
|
void GLViewImpl::QueuePointerEvent(PointerEventType type, PointerEventArgs^ args)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(mMutex);
|
|
||||||
std::shared_ptr<PointerEvent> e(new PointerEvent(type, args));
|
std::shared_ptr<PointerEvent> e(new PointerEvent(type, args));
|
||||||
mInputEvents.push(e);
|
mInputEvents.push(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLViewImpl::QueueEvent(std::shared_ptr<InputEvent>& event)
|
void GLViewImpl::QueueEvent(std::shared_ptr<InputEvent>& event)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(mMutex);
|
|
||||||
mInputEvents.push(event);
|
mInputEvents.push(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLViewImpl::ProcessEvents()
|
void GLViewImpl::ProcessEvents()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(mMutex);
|
std::shared_ptr<InputEvent> e;
|
||||||
|
while (mInputEvents.try_pop(e))
|
||||||
while (!mInputEvents.empty())
|
|
||||||
{
|
{
|
||||||
InputEvent* e = mInputEvents.front().get();
|
|
||||||
e->execute();
|
e->execute();
|
||||||
mInputEvents.pop();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,9 @@ THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
#include <agile.h>
|
#include <agile.h>
|
||||||
|
#include <concurrent_queue.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <wrl/client.h>
|
#include <wrl/client.h>
|
||||||
#include <mutex>
|
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <Keyboard-winrt.h>
|
#include <Keyboard-winrt.h>
|
||||||
|
|
||||||
|
@ -156,8 +156,9 @@ private:
|
||||||
Cocos2dMessageBoxDelegate^ m_messageBoxDelegate;
|
Cocos2dMessageBoxDelegate^ m_messageBoxDelegate;
|
||||||
Cocos2dEditBoxDelegate^ m_editBoxDelegate;
|
Cocos2dEditBoxDelegate^ m_editBoxDelegate;
|
||||||
|
|
||||||
std::queue<std::shared_ptr<InputEvent>> mInputEvents;
|
Concurrency::concurrent_queue<std::shared_ptr<InputEvent>> mInputEvents;
|
||||||
std::mutex mMutex;
|
//std::queue<std::shared_ptr<InputEvent>> mInputEvents;
|
||||||
|
//Concurrency::critical_section m_criticalSection;
|
||||||
|
|
||||||
Platform::Agile<Windows::UI::Core::CoreDispatcher> m_dispatcher;
|
Platform::Agile<Windows::UI::Core::CoreDispatcher> m_dispatcher;
|
||||||
Platform::Agile<Windows::UI::Xaml::Controls::Panel> m_panel;
|
Platform::Agile<Windows::UI::Xaml::Controls::Panel> m_panel;
|
||||||
|
|
Loading…
Reference in New Issue