Skip to content

make sure the CachedAssetReader/CachedAssetWriter dont throw synchronously #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 7, 2016

Conversation

jakemac53
Copy link
Contributor

The easier solution here would be to just mark all the methods as async, but we need to deal with the caches in a synchronous fashion. Those same caches can throw however, so wrapping everything in a try/catch seems to be the simplest solution.

@jakemac53 jakemac53 added this to the v0.2.0 milestone Mar 7, 2016
@kevmoo
Copy link
Member

kevmoo commented Mar 7, 2016

Yeah – why not make these methods async? Then you can get rid of all of the explicit Future creation

@jakemac53
Copy link
Contributor Author

Because of the caches, which need to be updated synchronously. For instance given the code:

Future.wait(assetIds.map((assetId) => reader.readAsString(assetId)));

All of those calls are dispatched synchronously, so the _pendingReads map needs to be updated synchronously.

@@ -58,27 +58,41 @@ class CachedAssetReader extends AssetReader {

@override
Future<bool> hasInput(AssetId id) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment as to why this is not async – it makes sense now, but docs would help.

@kevmoo
Copy link
Member

kevmoo commented Mar 7, 2016

LGTM – just add comments as to why we don't use async for future maintainers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants