Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-1975

ScriptEngineFactory implementations should declare their threading support

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      Our main script engines should declare in their ScriptEngineFactory implementations their behaviour with respect to multi thread as described in Section SCR.4.3.5.2 Metadata Methods of the JSR-223 Java Script API specification:

      Multithreaded Engine
      Multi-threaded Evaluation - The implementation of the API and the engine itself are capable of supporting concurrent evaluations by multiple threads on a single engine instance. However the exact behavior of such concurrent execution is ultimately determined by the script or scripts themselves. An engine which supports concurrent execution is "multi-threaded" in the same sense that the Java language is "multi-threaded": Evaluation by concurrent threads is allowed and produces side effects that can be seen by other threads. The threads may interact or not interact, utilize synchronization or not utilize synchronization, in scripting language dependent ways.

      Thread-Isolated Engine
      Satisfies the requirements for Multithreaded. Also, the side-effects for threads are isolated from one another. Specifically, the isolation limits the visibility of changes to the state of variables in the engine scope of the interpreter. Each thread will effectively have its own thread-local engine scope for the engine instance. Note that this does not limit the visibility of side effects outside the engine scope - for example, mutation of application-level Java objects.

      Stateless Engine
      Satisfies the requirements for Thread-Isolated. In addition, the mappings in the Bindings used as the engine scope of the ScriptEngine are not modified by any ScriptExecution. The keys in the Bindings and their associated values are exactly the same before and after each script execution.

      From this description, I would say :

      JavaScript is Multithreaded because as of SLING-1972 the variables are written back to the Engine scope bindings of the ScriptEngine instance (to support the SLING-1111 use case)
      JSP is state less because the Engine scope bindings are not modified by the ScriptEngine
      Java is state less because the Engine scope bindings are not modified by the ScriptEngine

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            fmeschbe Felix Meschberger
            fmeschbe Felix Meschberger
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment