2009-04-13 14:39:26 +02:00
|
|
|
/**
|
|
|
|
* This file is part of the KDE project
|
|
|
|
* Copyright (C) 2008 Kevin Ottens <ervin@kde.org>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public License
|
|
|
|
* along with this library; see the file COPYING.LIB. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
#include "pendingcall.h"
|
|
|
|
#include "pendingcall_p.h"
|
2009-04-13 14:39:26 +02:00
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
using namespace Jolie;
|
2009-04-13 14:39:26 +02:00
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
PendingCall::PendingCall(const PendingCall &other)
|
2009-04-13 14:39:26 +02:00
|
|
|
: d(other.d)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
PendingCall::PendingCall(QExplicitlySharedDataPointer<PendingCallPrivate> dd)
|
2009-04-13 14:39:26 +02:00
|
|
|
: d(dd)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
PendingCall::~PendingCall()
|
2009-04-13 14:39:26 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
PendingCall &PendingCall::operator=(const PendingCall &other)
|
2009-04-13 14:39:26 +02:00
|
|
|
{
|
|
|
|
d = other.d;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
bool PendingCall::isFinished() const
|
2009-04-13 14:39:26 +02:00
|
|
|
{
|
|
|
|
return d->isFinished;
|
|
|
|
}
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
Message PendingCall::reply() const
|
2009-04-13 14:39:26 +02:00
|
|
|
{
|
|
|
|
return d->reply;
|
|
|
|
}
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
void PendingCall::waitForFinished()
|
2009-04-13 14:39:26 +02:00
|
|
|
{
|
2009-04-25 15:50:35 +02:00
|
|
|
PendingCallWaiter waiter;
|
2009-04-13 14:39:26 +02:00
|
|
|
waiter.waitForFinished(d.data());
|
|
|
|
}
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
void PendingCallPrivate::setReply(const Message &message)
|
2009-04-13 14:39:26 +02:00
|
|
|
{
|
|
|
|
Q_ASSERT(message.id()==id);
|
|
|
|
isFinished = true;
|
|
|
|
reply = message;
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
foreach (PendingCallWaiter *waiter, waiters) {
|
2009-04-13 14:39:26 +02:00
|
|
|
waiter->eventLoop.quit();
|
|
|
|
}
|
|
|
|
|
|
|
|
waiters.clear();
|
|
|
|
}
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
void PendingCallWaiter::waitForFinished(PendingCallPrivate *pendingCall)
|
2009-04-13 14:39:26 +02:00
|
|
|
{
|
|
|
|
pendingCall->waiters << this;
|
|
|
|
eventLoop.exec();
|
|
|
|
}
|
2009-04-25 15:50:35 +02:00
|
|
|
|