val new_cancellable_lock (v:vprop)
  : STT (cancellable_lock v) v (fun _ -> emp)
let new_cancellable_lock v =
  let r = alloc true in
  intro_exists true (lock_inv_pred r v);
  let l = new_lock (lock_inv r v) in
  return ({lref = r; llock = l})
val new_cancellable_lock (v:vprop)
  : STT (cancellable_lock v) v (fun _ -> emp)
let new_cancellable_lock v =
let r = alloc true in
intro_exists true (lock_inv_pred r v);
let l = new_lock (lock_inv r v) in
return ({ lref = r; llock = l })
Steel.ST.CancellableSpinLock.fst.checked
Steel.ST.Util.fsti.checked Steel.ST.SpinLock.fsti.checked Steel.ST.Reference.fsti.checked Steel.ST.Effect.fsti.checked Steel.FractionalPermission.fst.checked prims.fst.checked FStar.Pervasives.fsti.checked FStar.Ghost.fsti.checked
Steel.ST.CancellableSpinLock.fst
Steel.Effect.Common.vprop Steel.ST.Util.return Steel.ST.CancellableSpinLock.cancellable_lock FStar.Ghost.hide FStar.Set.set Steel.Memory.iname FStar.Set.empty FStar.Algebra.CommMonoid.Equiv.__proj__CM__item__unit Steel.Effect.Common.req Steel.Effect.Common.rm Steel.ST.CancellableSpinLock.Mkcancellable_lock Steel.ST.SpinLock.lock Steel.ST.CancellableSpinLock.lock_inv Steel.ST.SpinLock.new_lock Prims.unit Steel.ST.Util.intro_exists Prims.bool Steel.ST.CancellableSpinLock.lock_inv_pred Steel.ST.Reference.ref Steel.ST.Reference.alloc
(*
   Copyright 2021 Microsoft Research

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

   Author: Aseem Rastogi
*)

module Steel.ST.CancellableSpinLock

open Steel.ST.Effect
open Steel.ST.Util
open Steel.FractionalPermission
open Steel.ST.Reference
open Steel.ST.SpinLock

module G = FStar.Ghost

[@@__reduce__]
let lock_inv_pred (r:ref bool) (v:vprop) : bool -> vprop =
  fun b -> pts_to r full_perm b `star` (if b then v else emp)  

[@@__reduce__]
let lock_inv (r:ref bool) (v:vprop) : vprop = exists_ (lock_inv_pred r v)

noeq
type cancellable_lock (v:vprop) = {
  lref   : ref bool;
  llock  : lock (lock_inv lref v)
}
val new_cancellable_lock (v:vprop)
  : STT (cancellable_lock v) v (fun _ -> emp)
v: Steel.Effect.Common.vprop
  -> Steel.ST.Effect.STT (Steel.ST.CancellableSpinLock.cancellable_lock v)