mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-02 14:04:46 -04:00
Deep redesign: phase #2
This commit is contained in:
@@ -1,3 +1,20 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2015 F4EXB //
|
||||
// written by Edouard Griffiths //
|
||||
// //
|
||||
// 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 as version 3 of the License, or //
|
||||
// //
|
||||
// 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 V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "util/messagequeue.h"
|
||||
#include "util/message.h"
|
||||
|
||||
@@ -10,29 +27,44 @@ MessageQueue::MessageQueue(QObject* parent) :
|
||||
|
||||
MessageQueue::~MessageQueue()
|
||||
{
|
||||
Message* cmd;
|
||||
while((cmd = accept()) != NULL)
|
||||
cmd->completed();
|
||||
Message* message;
|
||||
|
||||
while ((message = pop()) != 0)
|
||||
{
|
||||
delete message;
|
||||
}
|
||||
}
|
||||
|
||||
void MessageQueue::submit(Message* message)
|
||||
void MessageQueue::push(Message* message, bool emitSignal)
|
||||
{
|
||||
m_lock.lock();
|
||||
m_queue.append(message);
|
||||
m_lock.unlock();
|
||||
emit messageEnqueued();
|
||||
if (message)
|
||||
{
|
||||
m_lock.lock();
|
||||
m_queue.append(message);
|
||||
m_lock.unlock();
|
||||
}
|
||||
|
||||
if (emitSignal)
|
||||
{
|
||||
emit messageEnqueued();
|
||||
}
|
||||
}
|
||||
|
||||
Message* MessageQueue::accept()
|
||||
Message* MessageQueue::pop()
|
||||
{
|
||||
SpinlockHolder spinlockHolder(&m_lock);
|
||||
|
||||
if(m_queue.isEmpty())
|
||||
return NULL;
|
||||
else return m_queue.takeFirst();
|
||||
if (m_queue.isEmpty())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_queue.takeFirst();
|
||||
}
|
||||
}
|
||||
|
||||
int MessageQueue::countPending()
|
||||
int MessageQueue::size()
|
||||
{
|
||||
SpinlockHolder spinlockHolder(&m_lock);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user