0

Currently I'm working in a case study to integrate IronRuby into one of our core products. The exection of scripts in only possible in a synchronous manner, so I plan to execute the scripts in threads each.

But additionally I need a bit more control over the script execution, esp. I need a way to suspend a script and resume it at a later point in time. I think I need to store a stackframe incl. all variables at the time of script suspension, I call this a "runtime context". Alas I did not find a way to "monitor" the script execution in the required manner. (I checked out using call backs to the hosting language via dynamic objects, but this technique does not provide the required context.)

Does anybody out there have a clue how to approach this problem?

Nico
  • 1,554
  • 1
  • 23
  • 35

1 Answers1

1

You could potentially use the DLR's tracing API, which is normally used for implementing debuggers, but it's not well documented. You'd basically just "break" the script into the debugger and then continue execution later. There's some information here but it's a bit out of date.

Alternatively (and probably safer, depending on what your scripts are doing), your scripts could yield back to the host at defined points. In Python I'd use a generator; I'm not sure about Ruby, but even having the host provide a yield() function that the script can call should be enough.

Jeff Hardy
  • 7,632
  • 24
  • 24
  • Yes, I also think that this is a way to do it... but it is as you said; it is difficult to find a documentation. – Nico Jun 13 '12 at 16:17