Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add WebWorker Thread Support for Running Tasks (#348)
* Implement TaskThreadManager This commit implements a task manager variant that uses worker threads. A new worker is spawned for each new task that appears. All functionality should work, but hasn't been fully tested at this time. The TaskThreadManager is added to the export list for use in the frontend. * Fix Typos in TaskProcessManager THis commit fixes some various spelling typos found in the process manager files when implementing the task thread manager. * Use Task Thread Manager This commit updates the frontend to support using the task thread manager. The dev environment is adjusted to use it, but more testing should occur before it is used as the default. Further, a check was added to make sure worker threads are supported before using the TaskThreadManager. If the are not supported a warning message is printed and the TaskProcessManager is used instead. * Address PR Comments This commit addresses changes requested in PR: - TaskManager now has an Abort event defined. this is used instead of a string literal - TaskThreadManager now properly handles aborting on close - TaskThreadManager has changes to remove eslint errors - TaskThreadManager now checks for Webworker compatibliity in constructor. An error is thrown if there is no compatibility - TaskThreadManager and TaskProcessManager are refactored slightly to reduce code duplication - TaskManagerAdapter has better logic for falling back when worker threads are unavailable * Restructure Manager Files This commit restructures manager files into their own folders. This helps visually group similar classes/files. * Consolidate Shared Transformer Code This commit consolidates shared code between the two scripts that ran on child contexts (either process or thread). Most the the code has been extracted out to a base class and sub classes have been created for each implementation. * Refactor Managers to Consolidate Code This commit refactors similar code from the TaskProcessManager and TaskThreadManager into a new SplitContextTaskManager. This class is used as a base class for all future task managers that run in split contexts. Subclasses for processes and worker threads have been implemented and are now used by the frontend. * Fix SendProxy Bug This commit fixes a bug that prevented tasks from starting due to a typo in the send proxy side effect handler. * Fix Launcher Object Destroyed Bug This commit fixes a bug due to improper handling of the launcher ipc tunnel. When the tunnel closes, the launcher now does not attempt to send any messages, which prevents a crash like this from occurring. * Adjust TaskEvent Registration Logic This commit adjusts the logic surrounding registering for task events. Now the launcher will register for events as soon as the adapter is ready. This prevents any possibility of the task event chain not being set up properly to forward events to the frontend. This commit also hides console logs so they only show in dev mode and renames the manager.html file to a more appropriate launcher.html * Start Launcher when Transitioning to the Auth State This commit fixes a bug where deactivating the frontend would prevent the task launcher from starting again. A code path to launch the main window was missing the call to start the launcher as well. * Add Linter Exemptions for Certain Classes We have a requirement to use instance methods within the Transformer subclasses, but the implementations don't use `this`. Since this is a valid exception to the rule, an eslint comment is added to the top of both to convey this. See https://eslint.org/docs/rules/class-methods-use-this#exceptions for more details * Adjust Event Emitter Max Listeners This commit adjusts the max listeners for the TaskManager and TaskRunner event listeners. This allows many tasks (>25) to run without producing memory leak warnings. * Fix Delay and Webhook Event Passing This commit updates the event handlers to allow responding to a bulk event. In this case the ID passed will be 'ALL'. This allows a single event to be emitted when adjusting a delay or webhook in the TaskManager for all tasks. This also keeps the contract of purely using event based communication between the manager and runner. * Refactor Default TaskManager Implementation This commit updates the default single thread TaskManager Implementation to have similar syntax as the SplitContextTaskManager. This ensures all TaskManger implementations work when used. * Switch Defaults to use SplitThreadTaskManger This commit updates the default task manager to use the multi thread implementation. The set env var for prod is also updated to use thread instead of process. fixes #192
- Loading branch information