- DelphiTools - https://www.delphitools.info -

Threaded script execution

The SVN trunk version of DWS now supports threaded script execution.

Things went quite smoothly given that practically all classes got affected, yet all tests pass, including a special threaded torture test, so I’m reasonably confident ;-). The changes are however breaking backward compatibility, hopefully for the best.

Here are the major changes that will affect your code:

You can now have as many program executions for a given IdwsProgram as you wish, each execution will use memory for its heap & stack only, the compiled expression tree is shared. Both new interfaces use reference-counted memory management.

An IdwsProgramExecution is single threaded, but isn’t attached to any particular thread, meaning that it can be moved across threads freely, and re-run as many times as desired. A given TDelphiWebScript compiler component can still only compile one TdwsProgram at once. That said, you can have multiple TDelphiWebScript components, each compiling a different IdwsProgram in a different thread .

It goes without saying that of course, all the above is only valid if all the functions, classes and events you expose to the scripts are themselves thread-safe!