mirror of
https://github.com/simonbrunel/qtpromise.git
synced 2024-11-22 02:34:30 +08:00
Minor code style cleanup
This commit is contained in:
parent
da3ae12c02
commit
5e754d1b08
@ -1,8 +1,8 @@
|
|||||||
#ifndef _QTPROMISE_MODULE_H
|
#ifndef QTPROMISE_MODULE_H
|
||||||
#define _QTPROMISE_MODULE_H
|
#define QTPROMISE_MODULE_H
|
||||||
|
|
||||||
#include "../src/qtpromise/qpromise.h"
|
#include "../src/qtpromise/qpromise.h"
|
||||||
#include "../src/qtpromise/qpromisefuture.h"
|
#include "../src/qtpromise/qpromisefuture.h"
|
||||||
#include "../src/qtpromise/qpromisehelpers.h"
|
#include "../src/qtpromise/qpromisehelpers.h"
|
||||||
|
|
||||||
#endif // ifndef _QTPROMISE_MODULE_H
|
#endif // ifndef QTPROMISE_MODULE_H
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef _QTPROMISE_QPROMISE_H
|
#ifndef QTPROMISE_QPROMISE_H
|
||||||
#define _QTPROMISE_QPROMISE_H
|
#define QTPROMISE_QPROMISE_H
|
||||||
|
|
||||||
// QtPromise
|
// QtPromise
|
||||||
#include "qpromise_p.h"
|
#include "qpromise_p.h"
|
||||||
@ -95,4 +95,4 @@ private:
|
|||||||
|
|
||||||
#include "qpromise.inl"
|
#include "qpromise.inl"
|
||||||
|
|
||||||
#endif // ifndef _QTPROMISE_QPROMISE_H
|
#endif // ifndef QTPROMISE_QPROMISE_H
|
||||||
|
@ -12,7 +12,8 @@ public:
|
|||||||
: m_promise(new QPromise<T>(std::move(p)))
|
: m_promise(new QPromise<T>(std::move(p)))
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void operator()(const T& value) const {
|
void operator()(const T& value) const
|
||||||
|
{
|
||||||
resolve(value);
|
resolve(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +89,7 @@ inline QPromiseBase<T>::QPromiseBase(F resolver)
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
resolver(resolve);
|
resolver(resolve);
|
||||||
} catch(...) {
|
} catch (...) {
|
||||||
reject(std::current_exception());
|
reject(std::current_exception());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,7 +104,7 @@ inline QPromiseBase<T>::QPromiseBase(F resolver)
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
resolver(resolve, reject);
|
resolver(resolve, reject);
|
||||||
} catch(...) {
|
} catch (...) {
|
||||||
reject(std::current_exception());
|
reject(std::current_exception());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef _QTPROMISE_QPROMISE_P_H
|
#ifndef QTPROMISE_QPROMISE_P_H
|
||||||
#define _QTPROMISE_QPROMISE_P_H
|
#define QTPROMISE_QPROMISE_P_H
|
||||||
|
|
||||||
// QtPromise
|
// QtPromise
|
||||||
#include "qpromiseerror.h"
|
#include "qpromiseerror.h"
|
||||||
@ -284,7 +284,7 @@ struct PromiseCatcher
|
|||||||
error.rethrow();
|
error.rethrow();
|
||||||
} catch (const TArg& error) {
|
} catch (const TArg& error) {
|
||||||
PromiseDispatch<TArg, ResType>::call(error, handler, resolve, reject);
|
PromiseDispatch<TArg, ResType>::call(error, handler, resolve, reject);
|
||||||
} catch(...) {
|
} catch (...) {
|
||||||
reject(std::current_exception());
|
reject(std::current_exception());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -332,7 +332,7 @@ struct PromiseCatcher<T, std::nullptr_t, void>
|
|||||||
template <typename T> class PromiseData;
|
template <typename T> class PromiseData;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class PromiseDataBase: public QSharedData
|
class PromiseDataBase : public QSharedData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Error = QtPromise::QPromiseError;
|
using Error = QtPromise::QPromiseError;
|
||||||
@ -415,7 +415,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class PromiseData: public PromiseDataBase<T>
|
class PromiseData : public PromiseDataBase<T>
|
||||||
{
|
{
|
||||||
using Handler = std::pair<QPointer<QThread>, std::function<void(const T&)> >;
|
using Handler = std::pair<QPointer<QThread>, std::function<void(const T&)> >;
|
||||||
|
|
||||||
@ -463,7 +463,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
class PromiseData<void>: public PromiseDataBase<void>
|
class PromiseData<void> : public PromiseDataBase<void>
|
||||||
{
|
{
|
||||||
using Handler = std::pair<QPointer<QThread>, std::function<void()> >;
|
using Handler = std::pair<QPointer<QThread>, std::function<void()> >;
|
||||||
|
|
||||||
@ -494,4 +494,4 @@ private:
|
|||||||
|
|
||||||
} // namespace QtPromise
|
} // namespace QtPromise
|
||||||
|
|
||||||
#endif // ifndef _QTPROMISE_QPROMISE_H
|
#endif // ifndef QTPROMISE_QPROMISE_H
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef _QTPROMISE_QPROMISEERROR_H
|
#ifndef QTPROMISE_QPROMISEERROR_H
|
||||||
#define _QTPROMISE_QPROMISEERROR_H
|
#define QTPROMISE_QPROMISEERROR_H
|
||||||
|
|
||||||
// QtPromise
|
// QtPromise
|
||||||
#include "qpromiseglobal.h"
|
#include "qpromiseglobal.h"
|
||||||
@ -14,7 +14,7 @@ public:
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
throw value;
|
throw value;
|
||||||
} catch(...) {
|
} catch (...) {
|
||||||
m_exception = std::current_exception();
|
m_exception = std::current_exception();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,4 +55,4 @@ private:
|
|||||||
|
|
||||||
} // namespace QtPromise
|
} // namespace QtPromise
|
||||||
|
|
||||||
#endif // _QTPROMISE_QPROMISEERROR_H
|
#endif // QTPROMISE_QPROMISEERROR_H
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef _QTPROMISE_QPROMISEFUTURE_P_H
|
#ifndef QTPROMISE_QPROMISEFUTURE_P_H
|
||||||
#define _QTPROMISE_QPROMISEFUTURE_P_H
|
#define QTPROMISE_QPROMISEFUTURE_P_H
|
||||||
|
|
||||||
// Qt
|
// Qt
|
||||||
#include <QFutureWatcher>
|
#include <QFutureWatcher>
|
||||||
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
namespace QtPromise {
|
namespace QtPromise {
|
||||||
|
|
||||||
class QPromiseCanceledException: public QException
|
class QPromiseCanceledException : public QException
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void raise() const Q_DECL_OVERRIDE { throw *this; }
|
void raise() const Q_DECL_OVERRIDE { throw *this; }
|
||||||
@ -50,7 +50,7 @@ struct PromiseFulfill<QFuture<T> >
|
|||||||
} else {
|
} else {
|
||||||
PromiseFulfill<T>::call(watcher->result(), resolve, reject);
|
PromiseFulfill<T>::call(watcher->result(), resolve, reject);
|
||||||
}
|
}
|
||||||
} catch(...) {
|
} catch (...) {
|
||||||
reject(std::current_exception());
|
reject(std::current_exception());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ struct PromiseFulfill<QFuture<void> >
|
|||||||
} else {
|
} else {
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
} catch(...) {
|
} catch (...) {
|
||||||
reject(std::current_exception());
|
reject(std::current_exception());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,4 +94,4 @@ struct PromiseFulfill<QFuture<void> >
|
|||||||
|
|
||||||
} // namespace QtPromisePrivate
|
} // namespace QtPromisePrivate
|
||||||
|
|
||||||
#endif // _QTPROMISE_QPROMISEFUTURE_P_H
|
#endif // QTPROMISE_QPROMISEFUTURE_P_H
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef _QTPROMISE_QPROMISEGLOBAL_H
|
#ifndef QTPROMISE_QPROMISEGLOBAL_H
|
||||||
#define _QTPROMISE_QPROMISEGLOBAL_H
|
#define QTPROMISE_QPROMISEGLOBAL_H
|
||||||
|
|
||||||
// QtCore
|
// QtCore
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
@ -122,4 +122,4 @@ struct ArgsOf<const volatile T&&> : public ArgsOf<T>
|
|||||||
|
|
||||||
} // namespace QtPromisePrivate
|
} // namespace QtPromisePrivate
|
||||||
|
|
||||||
#endif // ifndef _QTPROMISE_QPROMISEGLOBAL_H
|
#endif // ifndef QTPROMISE_QPROMISEGLOBAL_H
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef _QTPROMISE_QPROMISEHELPERS_H
|
#ifndef QTPROMISE_QPROMISEHELPERS_H
|
||||||
#define _QTPROMISE_QPROMISEHELPERS_H
|
#define QTPROMISE_QPROMISEHELPERS_H
|
||||||
|
|
||||||
// QtPromise
|
// QtPromise
|
||||||
#include "qpromise_p.h"
|
#include "qpromise_p.h"
|
||||||
@ -39,4 +39,4 @@ QPromise<void> qPromiseAll(const QVector<QPromise<void> >& promises)
|
|||||||
|
|
||||||
} // namespace QtPromise
|
} // namespace QtPromise
|
||||||
|
|
||||||
#endif // _QTPROMISE_QPROMISEHELPERS_H
|
#endif // QTPROMISE_QPROMISEHELPERS_H
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
using namespace QtPromise;
|
using namespace QtPromise;
|
||||||
|
|
||||||
class tst_benchmark: public QObject
|
class tst_benchmark : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ public: // STATICS
|
|||||||
static Logs& logs() { static Logs logs; return logs; }
|
static Logs& logs() { static Logs logs; return logs; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Data: public Logger
|
struct Data : public Logger
|
||||||
{
|
{
|
||||||
Data(int v): Logger(), m_value(v) {}
|
Data(int v): Logger(), m_value(v) {}
|
||||||
int value() const { return m_value; }
|
int value() const { return m_value; }
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
using namespace QtPromise;
|
using namespace QtPromise;
|
||||||
|
|
||||||
class tst_future: public QObject
|
class tst_future : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ private Q_SLOTS:
|
|||||||
|
|
||||||
}; // class tst_future
|
}; // class tst_future
|
||||||
|
|
||||||
class MyException: public QException
|
class MyException : public QException
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MyException(const QString& error)
|
MyException(const QString& error)
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
using namespace QtPromise;
|
using namespace QtPromise;
|
||||||
|
|
||||||
class tst_helpers: public QObject
|
class tst_helpers : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
using namespace QtPromise;
|
using namespace QtPromise;
|
||||||
using namespace QtPromisePrivate;
|
using namespace QtPromisePrivate;
|
||||||
|
|
||||||
class tst_qpromise: public QObject
|
class tst_qpromise : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ using namespace QtPromise;
|
|||||||
using namespace QtPromisePrivate;
|
using namespace QtPromisePrivate;
|
||||||
|
|
||||||
// https://promisesaplus.com/#requirements
|
// https://promisesaplus.com/#requirements
|
||||||
class tst_requirements: public QObject
|
class tst_requirements : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
using namespace QtPromise;
|
using namespace QtPromise;
|
||||||
|
|
||||||
class tst_thread: public QObject
|
class tst_thread : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user