AngouriMath
Multithreading
Here we will cover using AngouriMath in multithreaded systems and realtime software.
Thread safety
Immutability allows us to guarantee, that any operations with an expression is thread-safe. It is also true that all methods and settings are thread-safe. To add to it, there exists no method in AngouriMath which would create a new thread. All methods are intentionally made single-threaded.Interruption of a method
It is a known problem that sometimes you do not want to wait until a procedure finishes. Symbolic algebra systems might take a while to execute the required command, not to mention bugs leading to infinite executions. At this point, you are offered an ability to interrupt such methods asvar cancellationTokenSource = new CancellationTokenSource();
// That goes instead of passing your token to methods
MathS.Multithreading.SetLocalCancellationToken(
cancellationTokenSource.Token);
// Then you normally run your task
var currTask = Task.Run(() => InputText.Text.Solve("x"),
cancellationTokenSource.Token);
try
{
await currTask;
LabelState.Text = currTask.Result.ToString();
}
catch (OperationCanceledException)
{
LabelState.Text = "Operation canceled";
}
Angouri © 2019-2023 · Project's repo · Site's repo · Octicons · Transparency · 1534 pages online