photonstorm/phaser — pull request #1356 by pnstickne (2014-11-24 06:13:38+00:00)
Title: Loader - parallel / extensible / documentation

Updates to the Loader to support parallel downloads (disabled by default) as well as adding future extensibility points. General documentation cleanup and jsdoc refinement.

There are no known incompatibilities with the current version; all local tests (including emulated Android) pass. With parallel downloading enable the order of the events may vary, which changes the results of the "Load Events" demo.

Parallel downloading can be enabled with `enableParallel` and the concurrency limit is controlled through `maxParallelDownloads`. Under simulated slower network connections parallel loading was a good bit faster than sequential loading. Even under a direct local host connection parallel loading was never slower; both results are fairly expected.

Synchronization points for parallel-downloads can be added using the `withSyncPoint` and `addSyncPoint` methods. Packs ('packfile' files) and Scripts ('script' files) are treated as synchronization points by default. This allows parallel downloads in generally while allowing synchronization of select resources if required.

Structurally the same process is used, with packs being merged into the filelist (as a 'packfile') format and the actual file objects, instead of indices, being threaded throughout the process. The separate state-loops have been combined into a single `processLoadQueue` but otherwise maintains the same flow and logic as previous.

Additional error handling / guards have been added, and the reported error message has been made more consistent. Invalid XML (when loading) no longer throws an exception but fails the particular file/asset that was being loaded.

Some public methods/properties have been marked as protected, but no (except in case of a should-have-been-private-method) public-facing interfaces have been removed. Some private methods have been renamed and/or removed.

This also incorporates the fast-cache path for Images tags that can _greatly_ speed up the responsiveness of image loading. (And should likely be treated as mutually exclusive with the other PR.)