Thread management

Problem Statement:

Scripts are executed within a language specific script runtime (also called script engine). We need to define the features of this runtime and the contract between the runtime and the scripts it runs with regard to threading.

Requirements:
Use Cases:

How could scripts be started? Scripts can run in different ways:
Analysis:

What is the concurrency model used by the script manager?

1. Do nothing to ensure thread safety. Allow any script to be run at any time in any context.

2. Use the same model StarOffice currently uses for StarBasic scripts, ie. allow only one script to run at a time.

3. Implement a threading model that allows the user to run one script per application/document context. This is similar to COM's Single Threaded Apartment (STA) Model where the application/document context would be the apartment in which only one script would be allowed to execute at a time. Before executing a script, the script engine would need to obtain a lock for the particular application/document context which it would release when the script has completed.

Suggested solution: 3



If we support concurrency via the STA, the same script could be run simultaneously in many contexts. What about scripts which are not thread safe?

1. Do nothing, script developers have to synchronize their own scripts

2. Use something like the SingleThreadModel interface of the Java servlet API, so that the developer can specify whether their script is thread safe or not in the deployment descriptor. The script manager ensures that SingleThreadModel scripts are not executed concurrently.

Suggested solution: 2