You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
await can be used on Future<T> as well as on T directly, i.e. it is perfectly fine to await a synchronous value (it will be wrapped into a Future under the hood).
That said, using await will always introduce an asynchronous gap and yield execution back to the event loop, which will introduce a delay in processing if used unnecessarily in a tight-loop, but I don't think this optimization is needed in this case.
withResource
is defined as:Future<T> withResource<T>(FutureOr<T> Function() callback)
Method body has this line:
return await callback();
From my understanding the correct way to write that is something like:
I found this while searching how to use
FutureOr<T>
correctly. Current code inPool
is not a good sample to follow, or am I missing something?The text was updated successfully, but these errors were encountered: