This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-Qt/example/doric/async/DoricAsyncResult.h

35 lines
566 B
C
Raw Normal View History

2021-02-04 16:59:58 +08:00
#ifndef ASYNCRESULT_H
#define ASYNCRESULT_H
#include <QJSValue>
2021-05-18 16:15:28 +08:00
#include "DoricExport.h"
2021-02-04 16:59:58 +08:00
#include "DoricSettableFuture.h"
2021-05-25 10:45:45 +08:00
static QString EMPTY("");
2021-02-04 16:59:58 +08:00
2021-05-18 16:15:28 +08:00
class DORIC_EXPORT DoricAsyncResult {
2021-02-04 16:59:58 +08:00
private:
2021-05-25 10:45:45 +08:00
QString result = EMPTY;
2021-02-04 16:59:58 +08:00
public:
2021-05-25 10:45:45 +08:00
std::function<void()> resultCallback;
std::function<void()> exceptionCallback;
std::function<void()> finishCallback;
2021-02-04 16:59:58 +08:00
2021-05-25 10:45:45 +08:00
DoricAsyncResult();
2021-02-04 16:59:58 +08:00
2021-05-25 10:45:45 +08:00
void setResult(QString result);
2021-02-04 16:59:58 +08:00
2021-05-25 10:45:45 +08:00
void setError(QString exception);
2021-02-04 16:59:58 +08:00
bool hasResult();
QJSValue getResult();
DoricSettableFuture *synchronous();
};
#endif // ASYNCRESULT_H