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
If the task is small enough you may not want to dispatch it to the thread pool.
In those cases it would be nice if you could simply create a promise that's already fulfilled, so that code that runs await on it can work in either case.
Supposing we can have a Task.return that creates a fulfilled promise, here's a contrived example:
let work, worklen = get_work ()inlet changes =(* skip dispatching to pool if workload is small *)if worklen <3thenList.map work ~f:(funx -> Task.return pool (thunk_opt x))
elseList.map work ~f:(funx -> Task.async pool (fun() -> thunk_opt x)))
inList.fold_left changes ~init:[]~f:(funaccres ->
matchTask.await pool res with|None -> acc
|Somey -> y :: acc)
The text was updated successfully, but these errors were encountered:
If the task is small enough you may not want to dispatch it to the thread pool.
In those cases it would be nice if you could simply create a promise that's already fulfilled, so that code that runs
await
on it can work in either case.Supposing we can have a
Task.return
that creates a fulfilled promise, here's a contrived example:The text was updated successfully, but these errors were encountered: