Check once for cancellation at the beginning of a parse
This commit is contained in:
parent
ec7756faa0
commit
ef87ed6130
1 changed files with 10 additions and 7 deletions
|
|
@ -1290,15 +1290,18 @@ static bool ts_parser__advance(
|
|||
}
|
||||
|
||||
for (;;) {
|
||||
// If a cancellation flag or a timeout was provided, then check every
|
||||
// time a fixed number of parse actions has been processed.
|
||||
if (++self->operation_count == OP_COUNT_PER_TIMEOUT_CHECK) {
|
||||
self->operation_count = 0;
|
||||
if (
|
||||
(self->cancellation_flag && atomic_load(self->cancellation_flag)) ||
|
||||
(!clock_is_null(self->end_clock) && clock_is_gt(clock_now(), self->end_clock))
|
||||
) {
|
||||
ts_subtree_release(&self->tree_pool, lookahead);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (
|
||||
self->operation_count == 0 &&
|
||||
((self->cancellation_flag && atomic_load(self->cancellation_flag)) ||
|
||||
(!clock_is_null(self->end_clock) && clock_is_gt(clock_now(), self->end_clock)))
|
||||
) {
|
||||
ts_subtree_release(&self->tree_pool, lookahead);
|
||||
return false;
|
||||
}
|
||||
|
||||
StackVersion last_reduction_version = STACK_VERSION_NONE;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue