complete pure call
This commit is contained in:
@@ -1,13 +1,31 @@
|
||||
#include "DoricAsyncResult.h"
|
||||
|
||||
#include <QWaitCondition>
|
||||
|
||||
DoricAsyncResult::DoricAsyncResult() {}
|
||||
|
||||
void DoricAsyncResult::setResult(QString result) { this->result = result; }
|
||||
void DoricAsyncResult::setResult(QString result) {
|
||||
this->result = result;
|
||||
this->resultCallback();
|
||||
}
|
||||
|
||||
void DoricAsyncResult::setError(QString exception) { this->result = exception; }
|
||||
|
||||
bool DoricAsyncResult::hasResult() { return !(result == EMPTY); }
|
||||
bool DoricAsyncResult::hasResult() { return !(result.isEmpty()); }
|
||||
|
||||
QJSValue DoricAsyncResult::getResult() { return this->result; }
|
||||
QString DoricAsyncResult::getResult() { return this->result; }
|
||||
|
||||
DoricSettableFuture *DoricAsyncResult::synchronous() { return NULL; }
|
||||
QString DoricAsyncResult::waitUntilResult() {
|
||||
if (hasResult()) {
|
||||
return this->result;
|
||||
}
|
||||
|
||||
QMutex mutex;
|
||||
QWaitCondition condition;
|
||||
this->resultCallback = [&condition]() { condition.wakeAll(); };
|
||||
|
||||
mutex.lock();
|
||||
condition.wait(&mutex);
|
||||
mutex.unlock();
|
||||
return this->result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user