You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
letrec addthandlebackoff=let before =Atomic.get t inlet after =if0<= before.balance then
{ balance = before.balance +1;
handles =handle :: before.handles }
else gc 1 [ handle ] before.handles
inifAtomic.compare_and_set t before after then handle
else add t handle (Backoff.once backoff)
letaddtvalue=
add t (Atomic.make (Some value)) Backoff.default
letrec removetbackoff=let before =Atomic.get t inlet after =if0<= before.balance then
{ before with balance = before.balance -2 }
else gc 0[] before.handles
inifnot (Atomic.compare_and_set t before after) then
remove t (Backoff.once backoff)
letremovethandle=ifAtomic.exchange handle None!=Nonethen
remove t Backoff.default
moduleBag : Bag=structtype'a t = 'astateAtomic.tlet create = create
let to_list = to_list
type'a handle = 'aoptionAtomic.tlet add = add
let remove = remove
end
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters