mirror of https://gitee.com/bigwinds/arangodb
make sleeping more accurate
This commit is contained in:
parent
8c1fe6ea4f
commit
02f9eb06f8
|
@ -4185,16 +4185,18 @@ AqlValue Functions::Sleep(ExpressionContext* expressionContext,
|
||||||
return AqlValue(AqlValueHintNull());
|
return AqlValue(AqlValueHintNull());
|
||||||
}
|
}
|
||||||
|
|
||||||
double const until = TRI_microtime() + value.toDouble();
|
double now = TRI_microtime();
|
||||||
|
double const until = now + value.toDouble();
|
||||||
|
|
||||||
while (TRI_microtime() < until) {
|
while (now < until) {
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(300));
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
|
|
||||||
if (expressionContext->killed()) {
|
if (expressionContext->killed()) {
|
||||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_QUERY_KILLED);
|
THROW_ARANGO_EXCEPTION(TRI_ERROR_QUERY_KILLED);
|
||||||
} else if (application_features::ApplicationServer::isStopping()) {
|
} else if (application_features::ApplicationServer::isStopping()) {
|
||||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_SHUTTING_DOWN);
|
THROW_ARANGO_EXCEPTION(TRI_ERROR_SHUTTING_DOWN);
|
||||||
}
|
}
|
||||||
|
now = TRI_microtime();
|
||||||
}
|
}
|
||||||
return AqlValue(AqlValueHintNull());
|
return AqlValue(AqlValueHintNull());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue