File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -106,13 +106,19 @@ NodeStatus TreeNode::executeTick()
106
106
if (!substituted)
107
107
{
108
108
using namespace std ::chrono;
109
+
109
110
auto t1 = steady_clock::now ();
111
+ // trick to prevent the compile from reordering the order of execution. See #861
112
+ // This makes sure that the code is executed at the end of this scope
113
+ std::shared_ptr<void > execute_later (nullptr , [&](...) {
114
+ auto t2 = steady_clock::now ();
115
+ if (monitor_tick)
116
+ {
117
+ monitor_tick (*this , new_status, duration_cast<microseconds>(t2 - t1));
118
+ }
119
+ });
120
+
110
121
new_status = tick ();
111
- auto t2 = steady_clock::now ();
112
- if (monitor_tick)
113
- {
114
- monitor_tick (*this , new_status, duration_cast<microseconds>(t2 - t1));
115
- }
116
122
}
117
123
}
118
124
You can’t perform that action at this time.
0 commit comments