The unpac monorepo manager self-hosting as a monorepo using unpac

Merge pull request #806 from dialohq/main

Prioritize returning Fiber.any value over cancelling quickly

authored by

Thomas Leonard and committed by
GitHub
62b9714f 1dce15f1

+8 -6
+2 -2
lib_eio/core/fiber.ml
··· 150 150 ) 151 151 in 152 152 match !r, Cancel.get_error parent_c with 153 - | OK r, None -> r 154 - | (OK _ | New), Some ex -> raise ex 153 + | OK r, _ -> r 154 + | New, Some ex -> raise ex 155 155 | Ex (ex, bt), None -> Printexc.raise_with_backtrace ex bt 156 156 | Ex ex1, Some ex2 -> 157 157 let bt2 = Printexc.get_raw_backtrace () in
+6 -4
tests/fiber.md
··· 191 191 Exception: Failure "Parent cancel". 192 192 ``` 193 193 194 - Cancelled from parent while already cancelling: 194 + Cancelled from parent while already cancelling 195 + (we return the value despite the cancellation): 195 196 196 197 ```ocaml 197 198 # run @@ fun () -> 198 199 Fiber.both 199 200 (fun () -> 200 - let _ = Fiber.first 201 + traceln "%s" @@ Fiber.first 201 202 (fun () -> "a") 202 - (fun () -> Fiber.yield (); failwith "cancel-b") 203 - in 203 + (fun () -> Fiber.yield (); failwith "cancel-b"); 204 + Fiber.check (); 204 205 traceln "Parent cancel failed" 205 206 ) 206 207 (fun () -> traceln "Cancelling parent"; failwith "Parent cancel"); 207 208 "not-reached";; 208 209 +Cancelling parent 210 + +a 209 211 Exception: Failure "Parent cancel". 210 212 ``` 211 213