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