mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 11:15:38 -05:00
fix fut: actually run all map/bind callbacks if pool is provided
This commit is contained in:
parent
c6157ac84d
commit
0177d6aee7
1 changed files with 15 additions and 9 deletions
24
src/fut.ml
24
src/fut.ml
|
|
@ -120,20 +120,26 @@ let bind ?on ~f fut : _ t =
|
||||||
| Error (e, bt) -> fail e bt
|
| Error (e, bt) -> fail e bt
|
||||||
in
|
in
|
||||||
|
|
||||||
|
let bind_and_fulfill r promise () =
|
||||||
|
let f_res_fut = apply_f_to_res r in
|
||||||
|
(* forward result *)
|
||||||
|
on_result f_res_fut (fun r -> fulfill promise r)
|
||||||
|
in
|
||||||
|
|
||||||
match peek fut with
|
match peek fut with
|
||||||
| Some r -> apply_f_to_res r
|
| Some r ->
|
||||||
|
(match on with
|
||||||
|
| None -> apply_f_to_res r
|
||||||
|
| Some on ->
|
||||||
|
let fut2, promise = make () in
|
||||||
|
Pool.run on (bind_and_fulfill r promise);
|
||||||
|
fut2)
|
||||||
| None ->
|
| None ->
|
||||||
let fut2, promise = make () in
|
let fut2, promise = make () in
|
||||||
on_result fut (fun r ->
|
on_result fut (fun r ->
|
||||||
let bind_and_fulfill () =
|
|
||||||
let f_res_fut = apply_f_to_res r in
|
|
||||||
(* forward result *)
|
|
||||||
on_result f_res_fut (fun r -> fulfill promise r)
|
|
||||||
in
|
|
||||||
|
|
||||||
match on with
|
match on with
|
||||||
| None -> bind_and_fulfill ()
|
| None -> bind_and_fulfill r promise ()
|
||||||
| Some on -> Pool.run on bind_and_fulfill);
|
| Some on -> Pool.run on (bind_and_fulfill r promise));
|
||||||
|
|
||||||
fut2
|
fut2
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue