diff options
author | Marja Hassinen <marja.hassinen@nokia.com> | 2010-12-20 15:17:47 +0200 |
---|---|---|
committer | Marja Hassinen <marja.hassinen@nokia.com> | 2010-12-20 15:17:47 +0200 |
commit | 0ace037efcfcef08236ab6a484ad23bb3e679367 (patch) | |
tree | af829c2bfa254f41e0c87c7d99ab9d2599a05383 | |
parent | 9e20d7399511fbbca8a461742c2713b32e90fa57 (diff) |
lcs: renamings related to the waitForSubscription.
The API addition is now: ContextProperty::waitForSubscription(bool block).
16 files changed, 45 insertions, 42 deletions
diff --git a/libcontextsubscriber/customer-tests/testplugins/timeplugin.cpp b/libcontextsubscriber/customer-tests/testplugins/timeplugin.cpp index a33a7bdc..dbb86022 100644 --- a/libcontextsubscriber/customer-tests/testplugins/timeplugin.cpp +++ b/libcontextsubscriber/customer-tests/testplugins/timeplugin.cpp @@ -59,11 +59,11 @@ void TimePlugin::unsubscribe(QSet<QString> keys) timer.stop(); } -void TimePlugin::waitUntilReadyAndBlock() +void TimePlugin::blockUntilReady() { } -void TimePlugin::waitForSubscriptionAndBlock(const QString& key) +void TimePlugin::blockUntilSubscribed(const QString& key) { } diff --git a/libcontextsubscriber/customer-tests/testplugins/timeplugin.h b/libcontextsubscriber/customer-tests/testplugins/timeplugin.h index 95c4c179..051548b0 100644 --- a/libcontextsubscriber/customer-tests/testplugins/timeplugin.h +++ b/libcontextsubscriber/customer-tests/testplugins/timeplugin.h @@ -46,8 +46,8 @@ public: explicit TimePlugin(); virtual void subscribe(QSet<QString> keys); virtual void unsubscribe(QSet<QString> keys); - virtual void waitUntilReadyAndBlock(); - virtual void waitForSubscriptionAndBlock(const QString& key); + virtual void blockUntilReady(); + virtual void blockUntilSubscribed(const QString& key); private Q_SLOTS: void onTimeout(); diff --git a/libcontextsubscriber/customer-tests/waitforsubs/testwaitforsubscription.cpp b/libcontextsubscriber/customer-tests/waitforsubs/testwaitforsubscription.cpp index ff0764fc..668157d9 100644 --- a/libcontextsubscriber/customer-tests/waitforsubs/testwaitforsubscription.cpp +++ b/libcontextsubscriber/customer-tests/waitforsubs/testwaitforsubscription.cpp @@ -74,7 +74,7 @@ void WaitForSubscriptionTests::waitAndBlockExisting() Helper h; QTimer::singleShot(0, &h, SLOT(onTimeout())); - prop.waitForSubscriptionAndBlock(); + prop.waitForSubscription(true); // The event loop hasn't spinned... QVERIFY(!h.processed); @@ -95,7 +95,7 @@ void WaitForSubscriptionTests::waitAndBlockNonExisting() Helper h; QTimer::singleShot(0, &h, SLOT(onTimeout())); - prop.waitForSubscriptionAndBlock(); + prop.waitForSubscription(true); // The event loop hasn't spinned... QVERIFY(!h.processed); @@ -166,7 +166,7 @@ void WaitForSubscriptionTests::waitAndBlockSubscribed() Helper h; QTimer::singleShot(0, &h, SLOT(onTimeout())); - prop.waitForSubscriptionAndBlock(); + prop.waitForSubscription(true); // The event loop hasn't spinned... QVERIFY(!h.processed); diff --git a/libcontextsubscriber/src/contextkitplugin.cpp b/libcontextsubscriber/src/contextkitplugin.cpp index 6df9bfb7..5ef4140e 100644 --- a/libcontextsubscriber/src/contextkitplugin.cpp +++ b/libcontextsubscriber/src/contextkitplugin.cpp @@ -400,7 +400,7 @@ void ContextKitPlugin::onNewValueChanged(QList<QVariant> value, } } -void ContextKitPlugin::waitUntilReadyAndBlock() +void ContextKitPlugin::blockUntilReady() { bool setSkip = providerAppearedQueued; // save this value onProviderAppeared(); @@ -412,7 +412,7 @@ void ContextKitPlugin::waitUntilReadyAndBlock() } } -void ContextKitPlugin::waitForSubscriptionAndBlock(const QString& key) +void ContextKitPlugin::blockUntilSubscribed(const QString& key) { // Force the subscriptions (that were scheduled) to happen now while (newProtocol && pendingKeys.size() > 0) { diff --git a/libcontextsubscriber/src/contextkitplugin.h b/libcontextsubscriber/src/contextkitplugin.h index 9d00a106..f2c3db94 100644 --- a/libcontextsubscriber/src/contextkitplugin.h +++ b/libcontextsubscriber/src/contextkitplugin.h @@ -71,8 +71,8 @@ public: void subscribe(QSet<QString> keys); void unsubscribe(QSet<QString> keys); void setDefaultNewProtocol(bool s); - void waitUntilReadyAndBlock(); - void waitForSubscriptionAndBlock(const QString& key); + void blockUntilReady(); + void blockUntilSubscribed(const QString& key); Q_SIGNALS: #ifdef DOXYGEN_ONLY diff --git a/libcontextsubscriber/src/contextproperty.cpp b/libcontextsubscriber/src/contextproperty.cpp index 82e2494e..3ed377b9 100644 --- a/libcontextsubscriber/src/contextproperty.cpp +++ b/libcontextsubscriber/src/contextproperty.cpp @@ -308,18 +308,22 @@ void ContextProperty::waitForSubscription() const } /// Suspends the execution of the current thread until subcription is complete -/// for this context property. This will e.g. block on a socket, so your events -/// will not be processed. Calling this function while the subscription is not -/// in progress (because it has completed already or because the property is -/// currently unsubscribed) does nothing. Calling this function is only allowed -/// for ContextProperty objects associated with the main thread, and calling -/// this function is only allowed in the main thread. -void ContextProperty::waitForSubscriptionAndBlock() const +/// for this context property. Spins the event loop if \a block is false, and +/// blocks (e.g., select / poll with a socket) if \a block is true. Calling this +/// function while the subscription is not in progress (because it has completed +/// already or because the property is currently unsubscribed) does nothing. +/// Calling this function with \a block = true is only allowed for +/// ContextProperty objects associated with the main thread, and calling this +/// function is only allowed in the main thread. +void ContextProperty::waitForSubscription(bool block) const { + if (!block) { + waitForSubscription(); + return; + } if (!priv->subscribed) return; - - priv->handle->waitForSubscriptionAndBlock(); + priv->handle->blockUntilSubscribed(); } /// Sets all of the ContextProperty instances immune to 'external diff --git a/libcontextsubscriber/src/contextproperty.h b/libcontextsubscriber/src/contextproperty.h index a9013b22..824097b7 100644 --- a/libcontextsubscriber/src/contextproperty.h +++ b/libcontextsubscriber/src/contextproperty.h @@ -47,8 +47,8 @@ public: void subscribe () const; void unsubscribe () const; - void waitForSubscription () const; - void waitForSubscriptionAndBlock () const; + void waitForSubscription() const; + void waitForSubscription(bool block) const; static void ignoreCommander(); static void setTypeCheck(bool typeCheck); diff --git a/libcontextsubscriber/src/iproviderplugin.h b/libcontextsubscriber/src/iproviderplugin.h index 0a0c3edb..49f0c48d 100644 --- a/libcontextsubscriber/src/iproviderplugin.h +++ b/libcontextsubscriber/src/iproviderplugin.h @@ -40,8 +40,8 @@ class IProviderPlugin : public QObject public: virtual void subscribe(QSet<QString> keys) = 0; virtual void unsubscribe(QSet<QString> keys) = 0; - virtual void waitUntilReadyAndBlock() = 0; - virtual void waitForSubscriptionAndBlock(const QString& key) = 0; + virtual void blockUntilReady() = 0; + virtual void blockUntilSubscribed(const QString& key) = 0; Q_SIGNALS: void ready(); diff --git a/libcontextsubscriber/src/propertyhandle.cpp b/libcontextsubscriber/src/propertyhandle.cpp index 595f1043..f8172a25 100644 --- a/libcontextsubscriber/src/propertyhandle.cpp +++ b/libcontextsubscriber/src/propertyhandle.cpp @@ -286,17 +286,16 @@ void PropertyHandle::onValueChanged() } } -void PropertyHandle::waitForSubscriptionAndBlock() +void PropertyHandle::blockUntilSubscribed() { - // Call waitForSubscriptionAndBlock once per each provider in - // pendingSubscriptions. Making the call might or might not result in - // removing the provider from pendingSubscriptions (depending on whether - // some events on the way are queued or not), so make no assumptions on - // that. + // Call blockUntilSubscribed once per each provider in pendingSubscriptions. + // Making the call might or might not result in removing the provider from + // pendingSubscriptions (depending on whether some events on the way are + // queued or not), so make no assumptions on that. QSet<Provider*> pendingSubscriptionsCopy = pendingSubscriptions; while (pendingSubscriptionsCopy.size() > 0) { Provider* provider = *(pendingSubscriptionsCopy.constBegin()); - provider->waitForSubscriptionAndBlock(myKey); + provider->blockUntilSubscribed(myKey); pendingSubscriptionsCopy.remove(provider); } } diff --git a/libcontextsubscriber/src/propertyhandle.h b/libcontextsubscriber/src/propertyhandle.h index 508944d9..220829f3 100644 --- a/libcontextsubscriber/src/propertyhandle.h +++ b/libcontextsubscriber/src/propertyhandle.h @@ -58,7 +58,7 @@ public: static void ignoreCommander(); static void setTypeCheck(bool typeCheck); - void waitForSubscriptionAndBlock(); + void blockUntilSubscribed(); Q_SIGNALS: void valueChanged(); diff --git a/libcontextsubscriber/src/provider.cpp b/libcontextsubscriber/src/provider.cpp index e28231d1..2395d504 100644 --- a/libcontextsubscriber/src/provider.cpp +++ b/libcontextsubscriber/src/provider.cpp @@ -397,7 +397,7 @@ void Provider::onPluginValueChanged(QString key, QVariant newValue) contextDebug() << "Received a property not subscribed to:" << key; } -void Provider::waitForSubscriptionAndBlock(const QString& key) +void Provider::blockUntilSubscribed(const QString& key) { // This function might be called before the plugin is constructed (since // it's constructed in a queued way). If so, construct it now. @@ -414,11 +414,11 @@ void Provider::waitForSubscriptionAndBlock(const QString& key) // When this is called, the plugin waits until it's ready, and emits the // ready() signal (the connection is not queued). As a result, we // handleSubscribes(). - plugin->waitUntilReadyAndBlock(); + plugin->blockUntilReady(); // And tell the plugin to block until the subscription of this key is // complete. - plugin->waitForSubscriptionAndBlock(key); + plugin->blockUntilSubscribed(key); } TimedValue Provider::get(const QString &key) const diff --git a/libcontextsubscriber/src/provider.h b/libcontextsubscriber/src/provider.h index 626ed8cd..789e2796 100644 --- a/libcontextsubscriber/src/provider.h +++ b/libcontextsubscriber/src/provider.h @@ -52,7 +52,7 @@ public: TimedValue get(const QString &key) const; void clearValues(); - void waitForSubscriptionAndBlock(const QString& key); + void blockUntilSubscribed(const QString& key); Q_SIGNALS: void subscribeFinished(Provider *provider, QString key); diff --git a/libcontextsubscriber/unit-tests/propertyhandle/provider.h b/libcontextsubscriber/unit-tests/propertyhandle/provider.h index 54111bc0..e87e5024 100644 --- a/libcontextsubscriber/unit-tests/propertyhandle/provider.h +++ b/libcontextsubscriber/unit-tests/propertyhandle/provider.h @@ -44,7 +44,7 @@ public: void unsubscribe(const QString &key); TimedValue get(const QString &key) const; void clearValues(); - void waitForSubscriptionAndBlock(const QString& key); + void blockUntilSubscribed(const QString& key); Q_SIGNALS: void subscribeFinished(QString key); diff --git a/libcontextsubscriber/unit-tests/propertyhandle/testpropertyhandle.cpp b/libcontextsubscriber/unit-tests/propertyhandle/testpropertyhandle.cpp index b823cdcb..8bb6ca1f 100644 --- a/libcontextsubscriber/unit-tests/propertyhandle/testpropertyhandle.cpp +++ b/libcontextsubscriber/unit-tests/propertyhandle/testpropertyhandle.cpp @@ -162,7 +162,7 @@ void Provider::unsubscribe(const QString& key) unsubscribeProviderNames << myName; } -void Provider::waitForSubscriptionAndBlock(const QString& key) +void Provider::blockUntilSubscribed(const QString& key) { } diff --git a/libcontextsubscriber/unit-tests/provider/contextkitplugin.h b/libcontextsubscriber/unit-tests/provider/contextkitplugin.h index 0c346836..9fdc5349 100644 --- a/libcontextsubscriber/unit-tests/provider/contextkitplugin.h +++ b/libcontextsubscriber/unit-tests/provider/contextkitplugin.h @@ -44,8 +44,8 @@ class ContextKitPlugin : public IProviderPlugin public: void subscribe(QSet<QString> keys); void unsubscribe(QSet<QString> keys); - void waitUntilReadyAndBlock(); - void waitForSubscriptionAndBlock(const QString& key); + void blockUntilReady(); + void blockUntilSubscribed(const QString& key); Q_SIGNALS: void ready(); diff --git a/libcontextsubscriber/unit-tests/provider/testprovider.cpp b/libcontextsubscriber/unit-tests/provider/testprovider.cpp index 8f22d909..1e030d40 100644 --- a/libcontextsubscriber/unit-tests/provider/testprovider.cpp +++ b/libcontextsubscriber/unit-tests/provider/testprovider.cpp @@ -133,11 +133,11 @@ void ContextKitPlugin::unsubscribe(QSet<QString> keys) unsubscribeRequested += keys; } -void ContextKitPlugin::waitForSubscriptionAndBlock(const QString& key) +void ContextKitPlugin::blockUntilSubscribed(const QString& key) { } -void ContextKitPlugin::waitUntilReadyAndBlock() +void ContextKitPlugin::blockUntilReady() { } |