IronBlock icon indicating copy to clipboard operation
IronBlock copied to clipboard

Run/Step/Pause/Resume

Open maciejmatuszak opened this issue 4 years ago • 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?

maciejmatuszak avatar Dec 11 '20 11:12 maciejmatuszak

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

maciejmatuszak avatar Dec 11 '20 11:12 maciejmatuszak

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

maciejmatuszak avatar Jun 10 '21 07:06 maciejmatuszak

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.

richorama avatar Jun 10 '21 07:06 richorama

@maciejmatuszak Are you still playing this?

yuzd avatar Dec 01 '21 23:12 yuzd

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: https://github.com/maciejmatuszak/IronBlock/compare/master...maciejmatuszak:variable_access

maciejmatuszak avatar Dec 02 '21 13:12 maciejmatuszak

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

danijerez avatar Jan 07 '23 17:01 danijerez