richorama/IronBlock

Run/Step/Pause/Resume

Opened this issue · 6 comments

Add ability to Run/Step/Pause/Resume at block granularity

depends on #36 #37

  • possibly use ManualResetEvent as mechanism to pause/resume
  • possibly use AutoResetEvent for step
  • can the base EventWaitHandle be used for both?

looks like the EventWaitHandle blocks the thread, use AsyncFactory.FromWaitHandle ?

Hi @richorama,
I think I come up with solution, check this branch, sorry for the major refactor, I was jumping around one file so much I split it to class per file. also added .editorsettings to make sure the formatting is uniform.

I split the IBlock.Evaluate to 3 steps:

  • void BeforeEvaluate(Context context);
  • object EvaluateInternal(Context context);
  • void AfterEvaluate(Context context);

The Context has now 2 events:

  • public event BeforeAfterBlockDelegate BeforeEvent;
  • public event BeforeAfterBlockDelegate AfterEvent;
    Those are triggered as expected at the beginning/end of a block.

To Step/Pause the execution check the RunnerContext, the BeforeEvent is hitting semaphore that is feeded by Step() function

Let me know what you think, I want to clean it up (some of the naming I think can be better) and add tests.

Maciej

Great idea. I was wondering about support some kind of middleware (or multiple middleware) functions in a similar kind of approach. Would be useful for adding telemetry/profiling as well.

yuzd commented

@maciejmatuszak Are you still playing this?

No longer have time to play with it but I got it to reasonable shape. check out this branch: block_before_after and refactoring of variable access on top of that: variable_access: maciejmatuszak/IronBlock@master...maciejmatuszak:variable_access

How was this? Is there a way to pause/cancel code evaluation?