diff options
Diffstat (limited to 'sandbox/multithreading-tests')
33 files changed, 0 insertions, 737 deletions
diff --git a/sandbox/multithreading-tests/Makefile.am b/sandbox/multithreading-tests/Makefile.am deleted file mode 100644 index 8da6191d..00000000 --- a/sandbox/multithreading-tests/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = new-property-in-thread old-property-in-thread single-thread stress-test wait-for-subscription-only-in-thread wait-for-subscription-thread using-backend-from-thread diff --git a/sandbox/multithreading-tests/new-property-in-thread/.gitignore b/sandbox/multithreading-tests/new-property-in-thread/.gitignore deleted file mode 100644 index 4390dc85..00000000 --- a/sandbox/multithreading-tests/new-property-in-thread/.gitignore +++ /dev/null @@ -1 +0,0 @@ -run-test diff --git a/sandbox/multithreading-tests/new-property-in-thread/Makefile.am b/sandbox/multithreading-tests/new-property-in-thread/Makefile.am deleted file mode 100644 index 59dc63a7..00000000 --- a/sandbox/multithreading-tests/new-property-in-thread/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -noinst_PROGRAMS = run-test -run_test_SOURCES = main.cpp thread.h - -AM_CXXFLAGS = $(QtCore_CFLAGS) -LIBS += $(QtCore_LIBS) - -# library dependency hack for seamless make in cli/ -AM_CXXFLAGS += -I$(srcdir)/../../src -run_test_LDADD = ../../src/libcontextsubscriber.la - -../../src/libcontextsubscriber.la: FORCE - $(MAKE) -C ../../src libcontextsubscriber.la -.PHONY: FORCE - -# moccing -nodist_run_test_SOURCES = mocs.cpp -QT_TOMOC = $(filter %.h, $(run_test_SOURCES)) -include $(top_srcdir)/am/qt.am diff --git a/sandbox/multithreading-tests/new-property-in-thread/main.cpp b/sandbox/multithreading-tests/new-property-in-thread/main.cpp deleted file mode 100644 index 3ab015fb..00000000 --- a/sandbox/multithreading-tests/new-property-in-thread/main.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include <contextproperty.h> - -#include "thread.h" - -#include <QCoreApplication> -#include <QThread> - -int main(int argc, char** argv) -{ - QCoreApplication app(argc, argv); - - qDebug() << "MAIN THREAD:" << QCoreApplication::instance()->thread(); - - // Start a thread which will create the ContextProperty. - Thread thread; - thread.start(); - - return app.exec(); -} - diff --git a/sandbox/multithreading-tests/new-property-in-thread/thread.h b/sandbox/multithreading-tests/new-property-in-thread/thread.h deleted file mode 100644 index dd9951b3..00000000 --- a/sandbox/multithreading-tests/new-property-in-thread/thread.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef THREAD_H -#define THREAD_H - -#include <contextproperty.h> - -#include <QThread> -#include <QDebug> - -class Listener : public QObject -{ - Q_OBJECT - -public: - Listener() - { - cp = new ContextProperty("test.int"); - connect(cp, SIGNAL(valueChanged()), this, SLOT(onValueChanged())); - } - - ContextProperty* cp; - -public slots: - void onValueChanged() - { - qDebug() << "Listener::valueChanged(), and current thread is" << QThread::currentThread(); - qDebug() << "The value is:" << cp->value(); - exit(1); - } -}; - -class Thread : public QThread -{ - Q_OBJECT - -protected: - void run() - { - qDebug() << "SUB THREAD:" << QThread::currentThread(); - Listener listener; - exec(); - } - -}; - -#endif diff --git a/sandbox/multithreading-tests/old-property-in-thread/.gitignore b/sandbox/multithreading-tests/old-property-in-thread/.gitignore deleted file mode 100644 index 4390dc85..00000000 --- a/sandbox/multithreading-tests/old-property-in-thread/.gitignore +++ /dev/null @@ -1 +0,0 @@ -run-test diff --git a/sandbox/multithreading-tests/old-property-in-thread/Makefile.am b/sandbox/multithreading-tests/old-property-in-thread/Makefile.am deleted file mode 100644 index 59dc63a7..00000000 --- a/sandbox/multithreading-tests/old-property-in-thread/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -noinst_PROGRAMS = run-test -run_test_SOURCES = main.cpp thread.h - -AM_CXXFLAGS = $(QtCore_CFLAGS) -LIBS += $(QtCore_LIBS) - -# library dependency hack for seamless make in cli/ -AM_CXXFLAGS += -I$(srcdir)/../../src -run_test_LDADD = ../../src/libcontextsubscriber.la - -../../src/libcontextsubscriber.la: FORCE - $(MAKE) -C ../../src libcontextsubscriber.la -.PHONY: FORCE - -# moccing -nodist_run_test_SOURCES = mocs.cpp -QT_TOMOC = $(filter %.h, $(run_test_SOURCES)) -include $(top_srcdir)/am/qt.am diff --git a/sandbox/multithreading-tests/old-property-in-thread/main.cpp b/sandbox/multithreading-tests/old-property-in-thread/main.cpp deleted file mode 100644 index c21c9d7f..00000000 --- a/sandbox/multithreading-tests/old-property-in-thread/main.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include <contextproperty.h> - -#include "thread.h" - -#include <QCoreApplication> -#include <QDebug> - -int main(int argc, char** argv) -{ - QCoreApplication app(argc, argv); - - qDebug() << "Main thread is" << QThread::currentThread(); - - ContextProperty* cp = new ContextProperty("test.int"); - delete cp; - // Creating a ContextProperty will result in creating a PropertyHandle, - // and the PropertyHandle is not deleted ever. - - // Start a thread which will create the same ContextProperty. - Thread thread; - thread.start(); - - return app.exec(); -} - diff --git a/sandbox/multithreading-tests/old-property-in-thread/thread.h b/sandbox/multithreading-tests/old-property-in-thread/thread.h deleted file mode 100644 index ec84afdf..00000000 --- a/sandbox/multithreading-tests/old-property-in-thread/thread.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef THREAD_H -#define THREAD_H - -#include <contextproperty.h> - -#include <QThread> -#include <QDebug> - -class Listener : public QObject -{ - Q_OBJECT - -public: - Listener() - { - cp = new ContextProperty("test.int"); - connect(cp, SIGNAL(valueChanged()), this, SLOT(onValueChanged())); - } - - ContextProperty* cp; - -public slots: - void onValueChanged() - { - qDebug() << "Listener::valueChanged(), and current thread is" << QThread::currentThread(); - qDebug() << "The value is:" << cp->value(); - exit(1); - } -}; - -class Thread : public QThread -{ - Q_OBJECT - -protected: - void run() - { - qDebug() << "Thread::run(), and current thread is" << QThread::currentThread(); - Listener listener; - exec(); - } - -}; - -#endif diff --git a/sandbox/multithreading-tests/single-thread/.gitignore b/sandbox/multithreading-tests/single-thread/.gitignore deleted file mode 100644 index 4390dc85..00000000 --- a/sandbox/multithreading-tests/single-thread/.gitignore +++ /dev/null @@ -1 +0,0 @@ -run-test diff --git a/sandbox/multithreading-tests/single-thread/Makefile.am b/sandbox/multithreading-tests/single-thread/Makefile.am deleted file mode 100644 index 010bc826..00000000 --- a/sandbox/multithreading-tests/single-thread/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -noinst_PROGRAMS = run-test -run_test_SOURCES = main.cpp listener.h - -AM_CXXFLAGS = $(QtCore_CFLAGS) -LIBS += $(QtCore_LIBS) - -# library dependency hack for seamless make in cli/ -AM_CXXFLAGS += -I$(srcdir)/../../src -run_test_LDADD = ../../src/libcontextsubscriber.la - -../../src/libcontextsubscriber.la: FORCE - $(MAKE) -C ../../src libcontextsubscriber.la -.PHONY: FORCE - -# moccing -nodist_run_test_SOURCES = mocs.cpp -QT_TOMOC = $(filter %.h, $(run_test_SOURCES)) -include $(top_srcdir)/am/qt.am diff --git a/sandbox/multithreading-tests/single-thread/listener.h b/sandbox/multithreading-tests/single-thread/listener.h deleted file mode 100644 index 9980f62a..00000000 --- a/sandbox/multithreading-tests/single-thread/listener.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef LISTENER_H -#define LISTENER_H - -#include <contextproperty.h> - -#include <QDebug> - -class Listener : public QObject -{ - Q_OBJECT - -public: - Listener() - { - cp = new ContextProperty("test.int"); - connect(cp, SIGNAL(valueChanged()), this, SLOT(onValueChanged())); - } - - ContextProperty* cp; - -public slots: - void onValueChanged() - { - qDebug() << "Listener::valueChanged()"; - qDebug() << "The value is:" << cp->value(); - exit(1); - } -}; - -#endif diff --git a/sandbox/multithreading-tests/single-thread/main.cpp b/sandbox/multithreading-tests/single-thread/main.cpp deleted file mode 100644 index 16dd2f65..00000000 --- a/sandbox/multithreading-tests/single-thread/main.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include <contextproperty.h> - -#include "listener.h" - -#include <QCoreApplication> - - -int main(int argc, char** argv) -{ - QCoreApplication app(argc, argv); - - Listener listener; - - return app.exec(); -} diff --git a/sandbox/multithreading-tests/stress-test/.gitignore b/sandbox/multithreading-tests/stress-test/.gitignore deleted file mode 100644 index e08dedad..00000000 --- a/sandbox/multithreading-tests/stress-test/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -run-test -cache.cdb diff --git a/sandbox/multithreading-tests/stress-test/1provider.cdb b/sandbox/multithreading-tests/stress-test/1provider.cdb Binary files differdeleted file mode 100644 index 58655ef3..00000000 --- a/sandbox/multithreading-tests/stress-test/1provider.cdb +++ /dev/null diff --git a/sandbox/multithreading-tests/stress-test/2providers.cdb b/sandbox/multithreading-tests/stress-test/2providers.cdb Binary files differdeleted file mode 100644 index 98324d4c..00000000 --- a/sandbox/multithreading-tests/stress-test/2providers.cdb +++ /dev/null diff --git a/sandbox/multithreading-tests/stress-test/Makefile.am b/sandbox/multithreading-tests/stress-test/Makefile.am deleted file mode 100644 index 59dc63a7..00000000 --- a/sandbox/multithreading-tests/stress-test/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -noinst_PROGRAMS = run-test -run_test_SOURCES = main.cpp thread.h - -AM_CXXFLAGS = $(QtCore_CFLAGS) -LIBS += $(QtCore_LIBS) - -# library dependency hack for seamless make in cli/ -AM_CXXFLAGS += -I$(srcdir)/../../src -run_test_LDADD = ../../src/libcontextsubscriber.la - -../../src/libcontextsubscriber.la: FORCE - $(MAKE) -C ../../src libcontextsubscriber.la -.PHONY: FORCE - -# moccing -nodist_run_test_SOURCES = mocs.cpp -QT_TOMOC = $(filter %.h, $(run_test_SOURCES)) -include $(top_srcdir)/am/qt.am diff --git a/sandbox/multithreading-tests/stress-test/main.cpp b/sandbox/multithreading-tests/stress-test/main.cpp deleted file mode 100644 index d7c334bd..00000000 --- a/sandbox/multithreading-tests/stress-test/main.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "thread.h" -#include <QCoreApplication> - -int main(int argc, char** argv) -{ - QCoreApplication app(argc, argv); - - int maxTasks = 0; - int maxTasks2 = 0; - int task = -1; - - if (argc > 1 && atoi(argv[1]) > 0) - maxTasks = atoi(argv[1]); - if (argc > 2 && atoi(argv[2]) > 0) - maxTasks2 = atoi(argv[2]); - if (argc > 3 && atoi(argv[3]) > 0) - task = atoi(argv[3]); - - TestRunner tests(maxTasks, "test.int", task); - TestRunner tests2(maxTasks2, "test2.int", task); - - return app.exec(); -} diff --git a/sandbox/multithreading-tests/stress-test/provider.py b/sandbox/multithreading-tests/stress-test/provider.py deleted file mode 100755 index 748929a4..00000000 --- a/sandbox/multithreading-tests/stress-test/provider.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/python -"""A test provider for the stress testing.""" - - -# change registry this often [msec] -registryChangeTimeout = 2017 - - -from ContextKit.flexiprovider import * -import gobject -import time -import os - -def update(): - t = time.time() - dt = int(1000*(t - round(t))) - gobject.timeout_add(1000 - dt, update) - v = int(round(t)) - fp.set('test.int', v) - fp.set('test.int2', v) - print t - return False - -pcnt = 0 -def chgRegistry(): - global pcnt - pcnt += 1 - if pcnt % 2: - print "1 provider" - os.system('cp 1provider.cdb tmp.cdb; mv tmp.cdb cache.cdb') - else: - print "2 providers" - os.system('cp 2providers.cdb tmp.cdb; mv tmp.cdb cache.cdb') - return True - - -gobject.timeout_add(1000, update) -# uncoment this to see the "Bus error" XXX -gobject.timeout_add(registryChangeTimeout, chgRegistry) - -fp = Flexiprovider([INT('test.int'), INT('test.int2')], 'my.test.provider', 'session') -fp.run() diff --git a/sandbox/multithreading-tests/stress-test/runme.sh b/sandbox/multithreading-tests/stress-test/runme.sh deleted file mode 100755 index a2aa73d6..00000000 --- a/sandbox/multithreading-tests/stress-test/runme.sh +++ /dev/null @@ -1,14 +0,0 @@ -# RunMe & ReadMe -# -# provider.py will run flexiprovider and update test.int every second to the POSIX time. -# Additionally, it will change the registry every two seconds. -# -# stress-test takes two int arguments: the number of threads using the first and the second provider. -# -# Compiling: for now, use qmake & make. Sorry. - -#xterm -e 'rlwrap ../../../python/context-provide my.test.provider int test.int 0 int test.int2 0' & -#xterm -e 'rlwrap ../../../python/context-provide my.test2.provider int test2.int 0 int test2.int2 0' & - -xterm -e './provider.py' & -CONTEXT_PROVIDERS=../stress-test/ ./run-test 3 3 diff --git a/sandbox/multithreading-tests/stress-test/thread.h b/sandbox/multithreading-tests/stress-test/thread.h deleted file mode 100644 index 44cbf7c8..00000000 --- a/sandbox/multithreading-tests/stress-test/thread.h +++ /dev/null @@ -1,135 +0,0 @@ -#ifndef STRESS_H -#define STRESS_H - -#include <contextproperty.h> - -#include <time.h> -#include <QThread> -#include <QDebug> - -#define NUM_TESTS 9 - -/* - * A thread doing something with a ContextProperty. - * - * First creates a ContextProperty tracking \c propertyName, then does some simple thing - * with it based on the \c task number, then finally the ContextProperty is deleted. - */ -class Thread : public QThread -{ - Q_OBJECT - -public: - Thread(const int task, const QString& propertyName) : task(task), propertyName(propertyName) {}; - -protected: - void run() { - // create property do something and delete it - ContextProperty* cp = new ContextProperty(propertyName); - int value, realValue; - - switch (task) { - case 1: // check value - cp->waitForSubscription(); - value = cp->value().toInt(); - realValue = time(0); - if (value != realValue && value != 0) { - msleep(100); // give it 0.1 sec to arrive - value = cp->value().toInt(); - if (value != realValue && value != 0) - qDebug() << "*** value mismatch:" << propertyName << value << realValue; - } - break; - - case 2: // wait 0-2000 msec before deleting - msleep(qrand()%2000); - break; - - case 3: // unsubscribe - cp->unsubscribe(); - break; - - case 4: // unsubscribe and wait a bit - cp->unsubscribe(); - msleep(qrand()%2000); - break; - - case 5: // unsubscribe and subscribe - cp->unsubscribe(); - cp->subscribe(); - break; - - case 6: // unsubscribe, wait a bit then subscribe and wait some more - cp->unsubscribe(); - msleep(qrand()%2000); - cp->subscribe(); - msleep(qrand()%2000); - break; - - case 7: // subscribe - cp->subscribe(); - break; - - case 8: // subscribe - msleep(qrand()%100); - cp->subscribe(); - msleep(qrand()%100); - break; - - default:; // just create and delete - } - - delete(cp); - exit(); - } - -private: - int task; - QString propertyName; - -}; - - -/* - * Starts \c maxThreads number of threads doing simple tests wit ContextProperty \c propertyName - * until stopped. The tasks are choosen randomly with equal weight. Whenever a thread stops - * an other one will start, ad infinitum. - */ -class TestRunner : public QObject -{ - Q_OBJECT - -private: - int maxThreads; - QSet<Thread*> threads; - QString propertyName; - int count; - int defaultTask; - -public: - TestRunner(const int maxThreads, const QString& propertyName, int task = -1) : - maxThreads(maxThreads), propertyName(propertyName), count(0), defaultTask(task) { - for (int i = 0; i < maxThreads; i++) - addThread(); - } - - void addThread() { - int task = defaultTask != -1 ? defaultTask : qrand() % NUM_TESTS ; - qDebug() << "** starting" << propertyName << task << "/" << ++count; - Thread* t = new Thread(task, propertyName); - QObject::connect(t, SIGNAL(finished()), this, SLOT(onThreadFinished())); - threads.insert(t); - t->start(); - } - -public slots: - void onThreadFinished() { - Thread* t = (Thread*) QObject::sender(); - if (threads.remove(t)) { - delete t; - addThread(); - } - } -}; - -#endif diff --git a/sandbox/multithreading-tests/using-backend-from-thread/.gitignore b/sandbox/multithreading-tests/using-backend-from-thread/.gitignore deleted file mode 100644 index 4390dc85..00000000 --- a/sandbox/multithreading-tests/using-backend-from-thread/.gitignore +++ /dev/null @@ -1 +0,0 @@ -run-test diff --git a/sandbox/multithreading-tests/using-backend-from-thread/Makefile.am b/sandbox/multithreading-tests/using-backend-from-thread/Makefile.am deleted file mode 100644 index b4cf1a5d..00000000 --- a/sandbox/multithreading-tests/using-backend-from-thread/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -noinst_PROGRAMS = run-test -run_test_SOURCES = main.cpp thread.h - -AM_CXXFLAGS = $(QtCore_CFLAGS) $(QtDBus_CFLAGS) -LIBS += $(QtCore_LIBS) $(QtDBus_LIBS) - -# library dependency hack for seamless make in cli/ -AM_CXXFLAGS += -I$(srcdir)/../../src -run_test_LDADD = ../../src/libcontextsubscriber.la - -../../src/libcontextsubscriber.la: FORCE - $(MAKE) -C ../../src libcontextsubscriber.la -.PHONY: FORCE - -# moccing -nodist_run_test_SOURCES = mocs.cpp -QT_TOMOC = $(filter %.h, $(run_test_SOURCES)) -include $(top_srcdir)/am/qt.am diff --git a/sandbox/multithreading-tests/using-backend-from-thread/main.cpp b/sandbox/multithreading-tests/using-backend-from-thread/main.cpp deleted file mode 100644 index a6a7c8aa..00000000 --- a/sandbox/multithreading-tests/using-backend-from-thread/main.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include <contextproperty.h> - -#include "thread.h" - -#include <QCoreApplication> -#include <QDebug> - -int main(int argc, char** argv) -{ - QCoreApplication app(argc, argv); - - qDebug() << "Main thread is" << QThread::currentThread(); - - // Start a thread which will use the backend - Thread* thread = new Thread(); - thread->start(); - - thread->wait(); - // Kill the thread - qDebug() << "Thread stopped, deleting it"; - delete thread; - qDebug() << "Entering main event loop"; - - return app.exec(); -} diff --git a/sandbox/multithreading-tests/using-backend-from-thread/thread.h b/sandbox/multithreading-tests/using-backend-from-thread/thread.h deleted file mode 100644 index cd77a298..00000000 --- a/sandbox/multithreading-tests/using-backend-from-thread/thread.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef THREAD_H -#define THREAD_H - -#include <contextproperty.h> -#include <contextpropertyinfo.h> - -#include <QThread> -#include <QDebug> - -class Listener : public QObject -{ - Q_OBJECT - -public: - Listener() - { - cp = new ContextProperty("test.int"); - qDebug() << "Provider is: " << cp->info()->providerDBusName(); - } - - ContextProperty* cp; -}; - -class Thread : public QThread -{ - Q_OBJECT - -protected: - void run() - { - qDebug() << "Thread::run(), and current thread is" << QThread::currentThread(); - Listener listener; - - qDebug() << "Returning from run"; - } - -}; - -#endif diff --git a/sandbox/multithreading-tests/wait-for-subscription-only-in-thread/.gitignore b/sandbox/multithreading-tests/wait-for-subscription-only-in-thread/.gitignore deleted file mode 100644 index 4390dc85..00000000 --- a/sandbox/multithreading-tests/wait-for-subscription-only-in-thread/.gitignore +++ /dev/null @@ -1 +0,0 @@ -run-test diff --git a/sandbox/multithreading-tests/wait-for-subscription-only-in-thread/Makefile.am b/sandbox/multithreading-tests/wait-for-subscription-only-in-thread/Makefile.am deleted file mode 100644 index 59dc63a7..00000000 --- a/sandbox/multithreading-tests/wait-for-subscription-only-in-thread/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -noinst_PROGRAMS = run-test -run_test_SOURCES = main.cpp thread.h - -AM_CXXFLAGS = $(QtCore_CFLAGS) -LIBS += $(QtCore_LIBS) - -# library dependency hack for seamless make in cli/ -AM_CXXFLAGS += -I$(srcdir)/../../src -run_test_LDADD = ../../src/libcontextsubscriber.la - -../../src/libcontextsubscriber.la: FORCE - $(MAKE) -C ../../src libcontextsubscriber.la -.PHONY: FORCE - -# moccing -nodist_run_test_SOURCES = mocs.cpp -QT_TOMOC = $(filter %.h, $(run_test_SOURCES)) -include $(top_srcdir)/am/qt.am diff --git a/sandbox/multithreading-tests/wait-for-subscription-only-in-thread/main.cpp b/sandbox/multithreading-tests/wait-for-subscription-only-in-thread/main.cpp deleted file mode 100644 index 1a1727b7..00000000 --- a/sandbox/multithreading-tests/wait-for-subscription-only-in-thread/main.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include <contextproperty.h> - -#include "thread.h" - -#include <QCoreApplication> -#include <QThread> - -int main(int argc, char** argv) -{ - QCoreApplication app(argc, argv); - - qDebug() << "MAIN THREAD:" << QCoreApplication::instance()->thread(); - - // Start a thread which will create the ContextProperty. - Thread thread; - thread.start(); - - qDebug() << "Entering main loop"; - return app.exec(); -} diff --git a/sandbox/multithreading-tests/wait-for-subscription-only-in-thread/thread.h b/sandbox/multithreading-tests/wait-for-subscription-only-in-thread/thread.h deleted file mode 100644 index e92af6f2..00000000 --- a/sandbox/multithreading-tests/wait-for-subscription-only-in-thread/thread.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef THREAD_H -#define THREAD_H - -#include <contextproperty.h> - -#include <QThread> -#include <QDebug> - -class Listener : public QObject -{ - Q_OBJECT - -public: - Listener() - { - cp = new ContextProperty("test.int"); - connect(cp, SIGNAL(valueChanged()), this, SLOT(onValueChanged())); - qDebug() << "**** Starting to wait"; - cp->waitForSubscription(); - qDebug() << "**** Waiting is done"; - qDebug() << "After waiting, the value is" << cp->value(); - sleep(1); - qDebug() << "After waiting 1 s more, the value is" << cp->value(); - - } - - ContextProperty* cp; - -public slots: - void onValueChanged() - { - qDebug() << "Listener::valueChanged(), and current thread is" << QThread::currentThread(); - qDebug() << "The value is:" << cp->value(); -// exit(1); - } -}; - -class Thread : public QThread -{ - Q_OBJECT - -protected: - void run() - { - qDebug() << "SUB THREAD:" << QThread::currentThread(); - Listener listener; - exec(); - } - -}; - -#endif diff --git a/sandbox/multithreading-tests/wait-for-subscription-thread/.gitignore b/sandbox/multithreading-tests/wait-for-subscription-thread/.gitignore deleted file mode 100644 index 4390dc85..00000000 --- a/sandbox/multithreading-tests/wait-for-subscription-thread/.gitignore +++ /dev/null @@ -1 +0,0 @@ -run-test diff --git a/sandbox/multithreading-tests/wait-for-subscription-thread/Makefile.am b/sandbox/multithreading-tests/wait-for-subscription-thread/Makefile.am deleted file mode 100644 index 59dc63a7..00000000 --- a/sandbox/multithreading-tests/wait-for-subscription-thread/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -noinst_PROGRAMS = run-test -run_test_SOURCES = main.cpp thread.h - -AM_CXXFLAGS = $(QtCore_CFLAGS) -LIBS += $(QtCore_LIBS) - -# library dependency hack for seamless make in cli/ -AM_CXXFLAGS += -I$(srcdir)/../../src -run_test_LDADD = ../../src/libcontextsubscriber.la - -../../src/libcontextsubscriber.la: FORCE - $(MAKE) -C ../../src libcontextsubscriber.la -.PHONY: FORCE - -# moccing -nodist_run_test_SOURCES = mocs.cpp -QT_TOMOC = $(filter %.h, $(run_test_SOURCES)) -include $(top_srcdir)/am/qt.am diff --git a/sandbox/multithreading-tests/wait-for-subscription-thread/main.cpp b/sandbox/multithreading-tests/wait-for-subscription-thread/main.cpp deleted file mode 100644 index 44390e2d..00000000 --- a/sandbox/multithreading-tests/wait-for-subscription-thread/main.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include <contextproperty.h> - -#include "thread.h" - -#include <QCoreApplication> -#include <QThread> - -int main(int argc, char** argv) -{ - QCoreApplication app(argc, argv); - - qDebug() << "MAIN THREAD:" << QCoreApplication::instance()->thread(); - - // Start a thread which will create the ContextProperty. - Thread thread; - thread.start(); - - sleep(2); - ContextProperty *cp = new ContextProperty("test.int"); - cp->waitForSubscription(); - qDebug() << "waiting is done in the main"; - - return app.exec(); -} - diff --git a/sandbox/multithreading-tests/wait-for-subscription-thread/thread.h b/sandbox/multithreading-tests/wait-for-subscription-thread/thread.h deleted file mode 100644 index 7766fe68..00000000 --- a/sandbox/multithreading-tests/wait-for-subscription-thread/thread.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef THREAD_H -#define THREAD_H - -#include <contextproperty.h> - -#include <QThread> -#include <QDebug> - -class Listener : public QObject -{ - Q_OBJECT - -public: - Listener() - { - cp = new ContextProperty("test.int"); - connect(cp, SIGNAL(valueChanged()), this, SLOT(onValueChanged())); - cp->waitForSubscription(); - qDebug() << "Waiting is done"; - } - - ContextProperty* cp; - -public slots: - void onValueChanged() - { - qDebug() << "Listener::valueChanged(), and current thread is" << QThread::currentThread(); - qDebug() << "The value is:" << cp->value(); -// exit(1); - } -}; - -class Thread : public QThread -{ - Q_OBJECT - -protected: - void run() - { - qDebug() << "SUB THREAD:" << QThread::currentThread(); - Listener listener; - exec(); - } - -}; - -#endif |