blob: a8e0f300a85549fcb0a51b478b2849233fc878a2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "debugwaitfunctionnode.h"
#include <vespa/vespalib/util/time.h>
namespace search::expression {
using vespalib::Serializer;
using vespalib::Deserializer;
using namespace std::chrono;
IMPLEMENT_EXPRESSIONNODE(DebugWaitFunctionNode, UnaryFunctionNode);
DebugWaitFunctionNode::DebugWaitFunctionNode()
: _waitTime(0.0),
_busyWait(true)
{ }
DebugWaitFunctionNode::~DebugWaitFunctionNode() = default;
DebugWaitFunctionNode::DebugWaitFunctionNode(ExpressionNode::UP arg, double waitTime, bool busyWait)
: UnaryFunctionNode(std::move(arg)),
_waitTime(waitTime),
_busyWait(busyWait)
{
}
using std::chrono::microseconds;
bool
DebugWaitFunctionNode::onExecute() const
{
vespalib::Timer::waitAtLeast(vespalib::from_s(_waitTime), _busyWait);
getArg().execute();
updateResult().assign(*getArg().getResult());
return true;
}
Serializer &
DebugWaitFunctionNode::onSerialize(Serializer & os) const
{
UnaryFunctionNode::onSerialize(os);
return os << _waitTime << _busyWait;
}
Deserializer &
DebugWaitFunctionNode::onDeserialize(Deserializer & is)
{
UnaryFunctionNode::onDeserialize(is);
is >> _waitTime >> _busyWait;
return is;
}
void
DebugWaitFunctionNode::visitMembers(vespalib::ObjectVisitor &visitor) const
{
UnaryFunctionNode::visitMembers(visitor);
visit(visitor, "waitTime", _waitTime);
visit(visitor, "busyWait", _busyWait);
}
}
// this function was added by ../../forcelink.sh
void forcelink_file_searchlib_expression_debugwaitfunctionnode() {}
|