Split PendingCall into PendingCall and PendingCallWatcher.
svn path=/branches/work/~ervin/qtjolie/; revision=976816
This commit is contained in:
parent
2d2aef5930
commit
c106afee83
@ -4,5 +4,6 @@ install( FILES
|
||||
QtJolie/Message
|
||||
QtJolie/MetaService
|
||||
QtJolie/PendingCall
|
||||
QtJolie/PendingCallWatcher
|
||||
QtJolie/Value
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/QtJolie COMPONENT Devel)
|
||||
|
@ -0,0 +1,2 @@
|
||||
#include "../qtjolie/pendingcallwatcher.h"
|
||||
|
@ -5,7 +5,16 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${QT_INCLUDE_DIR})
|
||||
|
||||
set(qtjolie_LIB_SRCS client.cpp clientthread.cpp value.cpp fault.cpp message.cpp metaservice.cpp pendingcall.cpp)
|
||||
set(qtjolie_LIB_SRCS
|
||||
client.cpp
|
||||
clientthread.cpp
|
||||
value.cpp
|
||||
fault.cpp
|
||||
message.cpp
|
||||
metaservice.cpp
|
||||
pendingcall.cpp
|
||||
pendingcallwatcher.cpp
|
||||
)
|
||||
|
||||
kde4_add_library(QtJolie SHARED ${qtjolie_LIB_SRCS})
|
||||
|
||||
@ -23,4 +32,5 @@ install(FILES
|
||||
message.h
|
||||
metaservice.h
|
||||
pendingcall.h
|
||||
pendingcallwatcher.h
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/qtjolie)
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "clientthread_p.h"
|
||||
#include "message.h"
|
||||
#include "pendingcall.h"
|
||||
#include "pendingcallwatcher.h"
|
||||
|
||||
using namespace Jolie;
|
||||
|
||||
@ -60,7 +61,7 @@ PendingCall Client::asyncCall(const Message &message)
|
||||
|
||||
Message Client::call(const Message &message)
|
||||
{
|
||||
PendingCall pending = asyncCall(message);
|
||||
PendingCallWatcher pending(asyncCall(message));
|
||||
pending.waitForFinished();
|
||||
return pending.reply();
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* This file is part of the KDE project
|
||||
* Copyright (C) 2008 Kevin Ottens <ervin@kde.org>
|
||||
* Copyright (C) 2009 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
|
||||
@ -20,6 +20,7 @@
|
||||
|
||||
#include "pendingcall.h"
|
||||
#include "pendingcall_p.h"
|
||||
#include "pendingcallwatcher.h"
|
||||
|
||||
using namespace Jolie;
|
||||
|
||||
@ -44,22 +45,6 @@ PendingCall &PendingCall::operator=(const PendingCall &other)
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool PendingCall::isFinished() const
|
||||
{
|
||||
return d->isFinished;
|
||||
}
|
||||
|
||||
Message PendingCall::reply() const
|
||||
{
|
||||
return d->reply;
|
||||
}
|
||||
|
||||
void PendingCall::waitForFinished()
|
||||
{
|
||||
PendingCallWaiter waiter;
|
||||
waiter.waitForFinished(d.data());
|
||||
}
|
||||
|
||||
void PendingCallPrivate::setReply(const Message &message)
|
||||
{
|
||||
Q_ASSERT(message.id()==id);
|
||||
@ -69,8 +54,12 @@ void PendingCallPrivate::setReply(const Message &message)
|
||||
foreach (PendingCallWaiter *waiter, waiters) {
|
||||
waiter->eventLoop.quit();
|
||||
}
|
||||
|
||||
waiters.clear();
|
||||
|
||||
foreach (PendingCallWatcher *watcher, watchers) {
|
||||
emit watcher->finished(watcher);
|
||||
}
|
||||
watchers.clear();
|
||||
}
|
||||
|
||||
void PendingCallWaiter::waitForFinished(PendingCallPrivate *pendingCall)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* This file is part of the KDE project
|
||||
* Copyright (C) 2008 Kevin Ottens <ervin@kde.org>
|
||||
* Copyright (C) 2009 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
|
||||
@ -37,13 +37,9 @@ public:
|
||||
|
||||
PendingCall &operator=(const PendingCall &other);
|
||||
|
||||
bool isFinished() const;
|
||||
Message reply() const;
|
||||
|
||||
void waitForFinished();
|
||||
|
||||
private:
|
||||
friend class Client;
|
||||
friend class PendingCallWatcher;
|
||||
|
||||
PendingCall(); // Not defined
|
||||
PendingCall(QExplicitlySharedDataPointer<PendingCallPrivate> dd);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* This file is part of the KDE project
|
||||
* Copyright (C) 2008 Kevin Ottens <ervin@kde.org>
|
||||
* Copyright (C) 2009 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
|
||||
@ -31,6 +31,7 @@ namespace Jolie
|
||||
{
|
||||
|
||||
class PendingCallPrivate;
|
||||
class PendingCallWatcher;
|
||||
|
||||
class PendingCallWaiter
|
||||
{
|
||||
@ -52,12 +53,14 @@ public:
|
||||
|
||||
private:
|
||||
friend class PendingCall;
|
||||
friend class PendingCallWatcher;
|
||||
friend class PendingCallWaiter;
|
||||
|
||||
qint64 id;
|
||||
bool isFinished;
|
||||
Message reply;
|
||||
QList<PendingCallWaiter*> waiters;
|
||||
QList<PendingCallWatcher*> watchers;
|
||||
};
|
||||
|
||||
} // namespace Jolie
|
||||
|
53
private/qtjolie-branch/qtjolie/pendingcallwatcher.cpp
Normal file
53
private/qtjolie-branch/qtjolie/pendingcallwatcher.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "pendingcallwatcher.h"
|
||||
|
||||
#include "pendingcall_p.h"
|
||||
|
||||
using namespace Jolie;
|
||||
|
||||
PendingCallWatcher::PendingCallWatcher(const PendingCall &other, QObject *parent)
|
||||
: QObject(parent), PendingCall(other.d)
|
||||
{
|
||||
d->watchers << this;
|
||||
}
|
||||
|
||||
PendingCallWatcher::~PendingCallWatcher()
|
||||
{
|
||||
d->watchers.removeAll(this);
|
||||
}
|
||||
|
||||
bool PendingCallWatcher::isFinished() const
|
||||
{
|
||||
return d->isFinished;
|
||||
}
|
||||
|
||||
Message PendingCallWatcher::reply() const
|
||||
{
|
||||
return d->reply;
|
||||
}
|
||||
|
||||
void PendingCallWatcher::waitForFinished()
|
||||
{
|
||||
PendingCallWaiter waiter;
|
||||
waiter.waitForFinished(d.data());
|
||||
}
|
||||
|
54
private/qtjolie-branch/qtjolie/pendingcallwatcher.h
Normal file
54
private/qtjolie-branch/qtjolie/pendingcallwatcher.h
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef QTJOLIE_PENDINGCALLWATCHER_H
|
||||
#define QTJOLIE_PENDINGCALLWATCHER_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
#include <qtjolie/pendingcall.h>
|
||||
|
||||
namespace Jolie
|
||||
{
|
||||
class Q_DECL_EXPORT PendingCallWatcher : public QObject, public PendingCall
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PendingCallWatcher(const PendingCall &call, QObject *parent=0);
|
||||
~PendingCallWatcher();
|
||||
|
||||
bool isFinished() const;
|
||||
Message reply() const;
|
||||
|
||||
void waitForFinished();
|
||||
|
||||
Q_SIGNALS:
|
||||
void finished(Jolie::PendingCallWatcher *self);
|
||||
|
||||
private:
|
||||
friend class PendingCallPrivate;
|
||||
|
||||
PendingCallWatcher(); // Not defined
|
||||
};
|
||||
|
||||
} // namespace Jolie
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user