Skip to content
Snippets Groups Projects
Commit a1e93de9 authored by Robbert Krebbers's avatar Robbert Krebbers
Browse files

Use option in spawn.

parent 98d7ce9b
No related branches found
No related tags found
No related merge requests found
...@@ -5,13 +5,13 @@ Import uPred. ...@@ -5,13 +5,13 @@ Import uPred.
Definition spawn : val := Definition spawn : val :=
λ: "f", λ: "f",
let: "c" := ref (InjL #0) in let: "c" := ref NONE in
Fork ("c" <- InjR ("f" #())) ;; "c". Fork ("c" <- SOME ("f" #())) ;; "c".
Definition join : val := Definition join : val :=
rec: "join" "c" := rec: "join" "c" :=
match: !"c" with match: !"c" with
InjR "x" => "x" SOME "x" => "x"
| InjL <> => "join" "c" | NONE => "join" "c"
end. end.
Global Opaque spawn join. Global Opaque spawn join.
...@@ -33,8 +33,8 @@ Context (heapN N : namespace). ...@@ -33,8 +33,8 @@ Context (heapN N : namespace).
Local Notation iProp := (iPropG heap_lang Σ). Local Notation iProp := (iPropG heap_lang Σ).
Definition spawn_inv (γ : gname) (l : loc) (Ψ : val iProp) : iProp := Definition spawn_inv (γ : gname) (l : loc) (Ψ : val iProp) : iProp :=
( lv, l lv (lv = InjLV #0 ( lv, l lv (lv = NONEV
v, lv = InjRV v (Ψ v own γ (Excl ()))))%I. v, lv = SOMEV v (Ψ v own γ (Excl ()))))%I.
Definition join_handle (l : loc) (Ψ : val iProp) : iProp := Definition join_handle (l : loc) (Ψ : val iProp) : iProp :=
(heapN N γ, heap_ctx heapN own γ (Excl ()) (heapN N γ, heap_ctx heapN own γ (Excl ())
...@@ -60,13 +60,13 @@ Proof. ...@@ -60,13 +60,13 @@ Proof.
wp_let. wp_alloc l as "Hl". wp_let. wp_let. wp_alloc l as "Hl". wp_let.
iPvs (own_alloc (Excl ())) as (γ) "Hγ"; first done. iPvs (own_alloc (Excl ())) as (γ) "Hγ"; first done.
iPvs (inv_alloc N _ (spawn_inv γ l Ψ) with "[Hl]") as "#?"; first done. iPvs (inv_alloc N _ (spawn_inv γ l Ψ) with "[Hl]") as "#?"; first done.
{ iNext. iExists (InjLV #0). iFrame; eauto. } { iNext. iExists NONEV. iFrame; eauto. }
wp_apply wp_fork. iSplitR "Hf". wp_apply wp_fork. iSplitR "Hf".
- iPvsIntro. wp_seq. iPvsIntro. iApply "HΦ". rewrite /join_handle. eauto. - iPvsIntro. wp_seq. iPvsIntro. iApply "HΦ". rewrite /join_handle. eauto.
- wp_focus (f _). iApply wp_wand_l. iFrame "Hf"; iIntros (v) "Hv". - wp_focus (f _). iApply wp_wand_l. iFrame "Hf"; iIntros (v) "Hv".
iInv N as (v') "[Hl _]"; first wp_done. iInv N as (v') "[Hl _]"; first wp_done.
wp_store. iPvsIntro. iSplit; [iNext|done]. wp_store. iPvsIntro. iSplit; [iNext|done].
iExists (InjRV v). iFrame. eauto. iExists (SOMEV v). iFrame. eauto.
Qed. Qed.
Lemma join_spec (Ψ : val iProp) l (Φ : val iProp) : Lemma join_spec (Ψ : val iProp) l (Φ : val iProp) :
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment