Library zoo_std.waiter_spsc__code
Require Import zoo.prelude.
Require Import zoo.language.typeclasses.
Require Import zoo.language.notations.
Require Import zoo_std.condition.
Require Import zoo_std.mutex.
Require Import zoo.options.
Notation "'waiter_spscู mutex'" := (
in_type "zoo_std.waiter_spsc.t" 0
)(in custom zoo_field
).
Notation "'waiter_spscู condition'" := (
in_type "zoo_std.waiter_spsc.t" 1
)(in custom zoo_field
).
Notation "'waiter_spscู flag'" := (
in_type "zoo_std.waiter_spsc.t" 2
)(in custom zoo_field
).
Definition waiter_spscู create : val :=
๐ณ๐๐ป โฝ โ
{ mutexู create (), conditionู create (), false }.
Definition waiter_spscู notify : val :=
๐ณ๐๐ป "t" โ
mutexู protect
"t".{waiter_spscู mutex}
(๐ณ๐๐ป โฝ โ "t" <-{waiter_spscู flag} true) โฎ
conditionู notify "t".{waiter_spscู condition}.
Definition waiter_spscู try_wait : val :=
๐ณ๐๐ป "t" โ
"t".{waiter_spscู flag}.
Definition waiter_spscู wait : val :=
๐ณ๐๐ป "t" โ
๐ถ๐ณ ยฌ waiter_spscู try_wait "t" ๐๐ต๐ฒ๐ป (
๐น๐ฒ๐ "mtx" = "t".{waiter_spscู mutex} ๐ถ๐ป
๐น๐ฒ๐ "cond" = "t".{waiter_spscู condition} ๐ถ๐ป
mutexู protect "mtx"
(๐ณ๐๐ป โฝ โ
conditionู wait_until
"cond"
"mtx"
(๐ณ๐๐ป โฝ โ "t".{waiter_spscู flag}))
).
Require Import zoo.language.typeclasses.
Require Import zoo.language.notations.
Require Import zoo_std.condition.
Require Import zoo_std.mutex.
Require Import zoo.options.
Notation "'waiter_spscู mutex'" := (
in_type "zoo_std.waiter_spsc.t" 0
)(in custom zoo_field
).
Notation "'waiter_spscู condition'" := (
in_type "zoo_std.waiter_spsc.t" 1
)(in custom zoo_field
).
Notation "'waiter_spscู flag'" := (
in_type "zoo_std.waiter_spsc.t" 2
)(in custom zoo_field
).
Definition waiter_spscู create : val :=
๐ณ๐๐ป โฝ โ
{ mutexู create (), conditionู create (), false }.
Definition waiter_spscู notify : val :=
๐ณ๐๐ป "t" โ
mutexู protect
"t".{waiter_spscู mutex}
(๐ณ๐๐ป โฝ โ "t" <-{waiter_spscู flag} true) โฎ
conditionู notify "t".{waiter_spscู condition}.
Definition waiter_spscู try_wait : val :=
๐ณ๐๐ป "t" โ
"t".{waiter_spscู flag}.
Definition waiter_spscู wait : val :=
๐ณ๐๐ป "t" โ
๐ถ๐ณ ยฌ waiter_spscู try_wait "t" ๐๐ต๐ฒ๐ป (
๐น๐ฒ๐ "mtx" = "t".{waiter_spscู mutex} ๐ถ๐ป
๐น๐ฒ๐ "cond" = "t".{waiter_spscู condition} ๐ถ๐ป
mutexู protect "mtx"
(๐ณ๐๐ป โฝ โ
conditionู wait_until
"cond"
"mtx"
(๐ณ๐๐ป โฝ โ "t".{waiter_spscู flag}))
).