Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. Compile and run the program below with
  2.  
  3. ```
  4. ocamlfind opt -linkpkg -package lwt.unix foo.ml && ./a.out
  5. ```
  6.  
  7. As written with `Lwt.pick`, `p2` is canceled first, its callback (registered by `Lwt.catch`) runs first, and the output is
  8.  
  9. ```
  10. p2's callback sees p3 pending
  11. p3's callback sees p2 failed
  12. ```
  13.  
  14. If changed to have `Lwt.npick` from the PR, `p3` is completed first, its callback (registered by `Lwt.bind`) runs first, and the output is
  15.  
  16. ```
  17. p3's callback sees p2 pending
  18. p2's callback sees p3 resolved
  19. ```
  20.  
  21. Ideally, changing `pick` to `npick` shouldn't produce this difference in callback execution order and seen states, as it makes refactoring relatively more dangerous.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement