/* * Copyright 2008 Ben Boeckel * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGBATTLE_ACTIONQUEUE #define SIGBATTLE_ACTIONQUEUE // Sigbattle includes #include "Global.h" #include "TeamMember.h" // Qt includes #include #include #include namespace Sigbattle { class SIGBATTLE_EXPORT ActionQueue : public QQueue { public: ActionQueue(); TeamMember::RequestedAction dequeue(); void enqueue(const TeamMember::RequestedAction& action); TeamMember::RequestedAction& head(); void lock(); void unlock(); private: QMutex m_mutex; }; inline ActionQueue::ActionQueue() : QQueue() { } inline TeamMember::RequestedAction ActionQueue::dequeue() { QMutexLocker locker(&m_mutex); return QQueue::dequeue(); } inline void ActionQueue::enqueue(const TeamMember::RequestedAction& action) { QMutexLocker locker(&m_mutex); QQueue::enqueue(action); } inline TeamMember::RequestedAction& ActionQueue::head() { QMutexLocker locker(&m_mutex); return QQueue::head(); } inline void ActionQueue::lock() { m_mutex.lock(); } inline void ActionQueue::unlock() { m_mutex.unlock(); } } #endif