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/doric/async/async_result.h

36 lines
543 B
C
Raw Normal View History

2021-01-28 17:06:40 +08:00
#ifndef ASYNCRESULT_H
#define ASYNCRESULT_H
2019-12-19 19:54:58 +08:00
2021-01-28 17:06:40 +08:00
#include <QJSValue>
2019-12-19 19:54:58 +08:00
#include "callback.h"
2021-01-28 17:06:40 +08:00
#include "settable_future.h"
2019-12-19 19:54:58 +08:00
2021-01-28 17:06:40 +08:00
static QJSValue EMPTY(QJSValue::NullValue);
2019-12-19 19:54:58 +08:00
2021-01-28 17:06:40 +08:00
class AsyncResult
{
2019-12-19 19:54:58 +08:00
private:
2021-01-28 17:06:40 +08:00
QJSValue result = EMPTY;
Callback *callback;
2019-12-19 19:54:58 +08:00
public:
2021-01-28 17:06:40 +08:00
AsyncResult();
AsyncResult(QJSValue result);
void setResult(QJSValue result);
void setError(QJSValue exception);
bool hasResult();
QJSValue getResult();
void setCallback(Callback *callback);
SettableFuture *synchronous();
2019-12-19 19:54:58 +08:00
};
2021-01-28 17:06:40 +08:00
#endif // ASYNCRESULT_H