mirror of https://github.com/axmolengine/axmol.git
removed mutex. use concurrent_queue for events
This commit is contained in:
parent
b483162128
commit
4dd48d5020
|
@ -531,33 +531,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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,7 @@ THE SOFTWARE.
|
|||
|
||||
#include <wrl/client.h>
|
||||
#include <d3d11_1.h>
|
||||
#include <mutex>
|
||||
#include <queue>
|
||||
#include <concurrent_queue.h>
|
||||
|
||||
#include <agile.h>
|
||||
#include <DirectXMath.h>
|
||||
|
@ -182,9 +181,7 @@ 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;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
|
Loading…
Reference in New Issue