Begin adding web workers (major commit).

Not well-tested yet, especially the web workers.

In addition to web workers, this completely rewrites both
`BackgroundWorker` and `ThreadPool`. It adds thread safety via the
`WorkOutput` object, adds flexibility by making `BackgroundWorker` build
off `ThreadPool`, and exposes an `eventSource` variable that tells
listeners which job dispatched a given event.

This improves the old web worker implementation by reusing the _entire_
JS file. This is slower but ensures that all classes are available,
simplifying the end user experience. Web workers are now forbidden from
using instance functions, which also simplifies things. And finally, the
code attempts to restore the prototypes of all class instances passed
across threads, though this relies on the exact way Haxe generates
JavaScript, and may not work in Haxe 3 or Haxe 5.
This commit is contained in:
Joseph Cloutier
2022-02-22 19:27:51 -05:00
parent b67d4304ff
commit 218f763977
7 changed files with 1349 additions and 695 deletions

View File

@@ -74,6 +74,9 @@
<section unless="display">
<!-- TODO: use target.threaded keyword, add html5 to the list. -->
<define name="lime-threads" if="cs || neko || cpp || java || python || hl" unless="force-synchronous || force_synchronous || emscripten" />
<section if="cpp ${${haxe_ver} < 3.3}" unless="static_link">
<ndll name="std" haxelib="hxcpp" />
<ndll name="regexp" haxelib="hxcpp" />