Skip to content

Commit

Permalink
Introduce Advanced API and ProcessTasks (#1499)
Browse files Browse the repository at this point in the history
  • Loading branch information
lahma authored Mar 16, 2023
1 parent 6333d28 commit 98c7f0b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Jint.Tests.PublicInterface/AdvancedApiTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Jint.Tests.PublicInterface;

public class AdvancedApiTests
{
[Fact]
public void CanProcessTasks()
{
var engine = new Engine();
engine.Advanced.ProcessTasks();
}
}
24 changes: 24 additions & 0 deletions Jint/Engine.Advanced.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace Jint;

public partial class Engine
{
public AdvancedOperations Advanced { get; }
}

public class AdvancedOperations
{
private readonly Engine _engine;

public AdvancedOperations(Engine engine)
{
_engine = engine;
}

/// <summary>
/// Forcefully processes the current task queues (micro and regular), this API may break and change behavior!
/// </summary>
public void ProcessTasks()
{
_engine.RunAvailableContinuations();
}
}
2 changes: 2 additions & 0 deletions Jint/Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public Engine(Options options) : this((e, o) => e.Options = options)
/// <remarks>The provided engine instance in callback is not guaranteed to be fully configured</remarks>
public Engine(Action<Engine, Options> options)
{
Advanced = new AdvancedOperations(this);

_executionContexts = new ExecutionContextStack(2);

Options = new Options();
Expand Down

0 comments on commit 98c7f0b

Please sign in to comment.