Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for CancellationToken in Fire method #221

Closed
a046 opened this issue Apr 9, 2020 · 2 comments
Closed

Add support for CancellationToken in Fire method #221

a046 opened this issue Apr 9, 2020 · 2 comments
Milestone

Comments

@a046
Copy link
Contributor

a046 commented Apr 9, 2020

What are your thoughts on adding a CancellationToken argument in Session.Fire()? This would be to allow the execution to halt if it's taking too long (likely infinitely looping due to chaining).

It seems a check to actionContext.IsHalted is already checked in each iteration, so i'm sure the two could somehow be merged if efficiency is a problem.

I think long running actions could be handled by exposing the cancellation token on IContext which would only leave potential gaps if the matching process/RETE maintenance is slow and not cancellable.

@snikolayev
Copy link
Member

@a046 I think this is a reasonable improvement.
For Fire method itself, you could just call Fire(1) in a loop and bail out if you get too many cycles. But it does not help with long-running actions, so I think your proposal makes sense.

@snikolayev snikolayev changed the title [Enhancement] Support CancellationToken? Add support for CancellationToken in Fire method Apr 12, 2020
@a046
Copy link
Contributor Author

a046 commented Apr 20, 2020

Just another thought, a comprehensive solution might also support/check the CancellationToken in RuleCompiler.Compile as that could be a slow/costly part.

Maybe also InsertAll for the initial seeding of the engine with facts? Unless you'd recommend calling Insert in a loop externally.

@snikolayev snikolayev added this to the 0.9.1 milestone May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants