Skip to content

Commit 6b8de3f

Browse files
committed
Simplify
1 parent 56ac226 commit 6b8de3f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/core/ds/atomicLazy.ml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ let from_fun f =
1010
{ value = None; mutex = Mutex.create (); compute = (fun () -> f()) }
1111

1212
let force lazy_val =
13-
if Option.is_none lazy_val.value then
14-
Mutex.protect lazy_val.mutex (fun () ->
15-
let result = lazy_val.compute () in
16-
lazy_val.value <- Some result;
17-
);
1813
match lazy_val.value with
19-
| Some v -> v
20-
| None -> failwith "Value not computed"
14+
| None ->
15+
Mutex.protect lazy_val.mutex (fun () ->
16+
let result = lazy_val.compute () in
17+
lazy_val.value <- Some result;
18+
result
19+
)
20+
| Some v -> v
2121

0 commit comments

Comments
 (0)