trikset/trikRuntime — pull request #56 by dvvrd (2014-09-11 19:41:22+00:00)
Title: Multithreading support for QtScript runtime

QtScript engine extended with multithreading API.
Now someone can write Threding.start(...) accepting function and in will be invoked in new OS thread.
LIMITATIONS:
Since QScriptEngine is non-thread-safe there exist some restrictions on multithreaded script.
1) Threads do not see memory modifications made by other threads. That is because different threads are invoked by different script engines with own global objects. Moreover on new thread start old script`s memory is fully copied what badly harms performance.
2) The multithreaded script must not contain useful actions in the global context (function calls, variable initializations and so on in the global context is restricted). The reason is in non-thread-safety of script engine. We must run scripts by separate script engines and thus to have an opportunity to start concrete function from the given file. But QScriptEngine API has no such possibility so we should append function call to the end of the script. So if script will run some actions in the global context they will be invoked on each thread start.

See trikScriptRunner::Threading class for threading API description.