@@ -236,7 +236,7 @@ module SetReductions =
236236 | None ->
237237 ()
238238
239- override x.InputChangedObject ( t , o ) =
239+ override x.InputChangedObject ( _t , o ) =
240240 if isNull o.Tag then
241241 #if FABLE_ COMPILER
242242 let o = unbox< aval< 'b>> o
@@ -369,7 +369,7 @@ module AdaptiveHashSetImplementation =
369369 type EmptySet < 'T > private () =
370370 static let instance = EmptySet< 'T>() :> aset<_>
371371 let content = AVal.constant HashSet.empty
372- let reader = new History.Readers.EmptyReader< CountingHashSet< 'T>, HashSetDelta< 'T>>( CountingHashSet.trace) :> IHashSetReader< 'T>
372+ let reader = History.Readers.EmptyReader< CountingHashSet< 'T>, HashSetDelta< 'T>>( CountingHashSet.trace) :> IHashSetReader< 'T>
373373 static member Instance = instance
374374
375375 member x.Content = content
@@ -389,7 +389,7 @@ module AdaptiveHashSetImplementation =
389389 member x.Content = value
390390
391391 member x.GetReader () =
392- new History.Readers.ConstantReader<_,_>(
392+ History.Readers.ConstantReader<_,_>(
393393 CountingHashSet.trace,
394394 lazy ( HashSet.addAll content.Value),
395395 lazy ( CountingHashSet.ofHashSet content.Value)
@@ -415,15 +415,15 @@ module AdaptiveHashSetImplementation =
415415 HashSetDelta.map ( fun d ->
416416 let v = d.Value
417417 if d.Count = 1 then Add( cache.Invoke v)
418- elif d.Count = - 1 then Rem( cache.Revoke v)
418+ elif d.Count = - 1 then Rem( cache.RevokeUnsafe v)
419419 else unexpected()
420420 )
421421
422422 override x.Compute ( token ) =
423423 reader.GetChanges token |> HashSetDelta.map ( fun d ->
424424 let v = d.Value
425425 if d.Count = 1 then Add( cache.Invoke v)
426- elif d.Count = - 1 then Rem( cache.Revoke v)
426+ elif d.Count = - 1 then Rem( cache.RevokeUnsafe v)
427427 else unexpected()
428428 )
429429
@@ -463,7 +463,7 @@ module AdaptiveHashSetImplementation =
463463 if d.Count = 1 then
464464 Add( cache.Invoke v) |> Some
465465 elif d.Count = - 1 then
466- match cache.RevokeAndGetDeletedTotal v with
466+ match cache.TryRevokeAndGetDeleted v with
467467 | ValueSome ( del, v) ->
468468 if del then ( v :> IDisposable) .Dispose()
469469 Rem v |> Some
@@ -487,15 +487,15 @@ module AdaptiveHashSetImplementation =
487487 HashSetDelta.collect ( fun d ->
488488 match d with
489489 | Add( 1 , v) -> HashSet.computeDelta HashSet.empty ( cache.Invoke v)
490- | Rem( 1 , v) -> HashSet.computeDelta ( cache.Revoke v) HashSet.empty
490+ | Rem( 1 , v) -> HashSet.computeDelta ( cache.RevokeUnsafe v) HashSet.empty
491491 | _ -> unexpected()
492492 )
493493
494494 override x.Compute ( token ) =
495495 reader.GetChanges token |> HashSetDelta.collect ( fun d ->
496496 match d with
497497 | Add( 1 , v) -> HashSet.computeDelta HashSet.empty ( cache.Invoke v)
498- | Rem( 1 , v) -> HashSet.computeDelta ( cache.Revoke v) HashSet.empty
498+ | Rem( 1 , v) -> HashSet.computeDelta ( cache.RevokeUnsafe v) HashSet.empty
499499 | _ -> unexpected()
500500 )
501501
@@ -516,9 +516,9 @@ module AdaptiveHashSetImplementation =
516516 | Some v -> Some ( Add v)
517517 | None -> None
518518 elif d.Count = - 1 then
519- match cache.Revoke v with
520- | Some v -> Some ( Rem v)
521- | None -> None
519+ match cache.TryRevoke v with
520+ | ValueSome ( Some v) -> Some ( Rem v)
521+ | _ -> None
522522 else
523523 unexpected()
524524 )
@@ -531,9 +531,9 @@ module AdaptiveHashSetImplementation =
531531 | Some v -> Some ( Add v)
532532 | None -> None
533533 elif d.Count = - 1 then
534- match cache.Revoke v with
535- | Some v -> Some ( Rem v)
536- | None -> None
534+ match cache.TryRevoke v with
535+ | ValueSome ( Some v) -> Some ( Rem v)
536+ | _ -> None
537537 else
538538 unexpected()
539539 )
@@ -551,15 +551,15 @@ module AdaptiveHashSetImplementation =
551551 HashSetDelta.filter ( fun d ->
552552 let v = d.Value
553553 if d.Count = 1 then cache.Invoke v
554- elif d.Count = - 1 then cache.Revoke v
554+ elif d.Count = - 1 then cache.RevokeUnsafe v
555555 else unexpected()
556556 )
557557
558558 override x.Compute ( token ) =
559559 r.GetChanges token |> HashSetDelta.filter ( fun d ->
560560 let v = d.Value
561561 if d.Count = 1 then cache.Invoke v
562- elif d.Count = - 1 then cache.Revoke v
562+ elif d.Count = - 1 then cache.RevokeUnsafe v
563563 else unexpected()
564564 )
565565
@@ -588,7 +588,7 @@ module AdaptiveHashSetImplementation =
588588
589589 elif d.Count = - 1 then
590590 // r is no longer dirty since we either pull or destroy it here.
591- let struct ( deleted , r ) = cache.RevokeAndGetDeleted v
591+ let struct ( deleted , r ) = cache.RevokeAndGetDeletedUnsafe v
592592 dirty.Remove r |> ignore
593593 if deleted then
594594 // in case r was not dirty we need to explicitly remove ourselves
@@ -843,7 +843,7 @@ module AdaptiveHashSetImplementation =
843843 r.GetChanges token
844844
845845 elif d.Count = - 1 then
846- match cache.RevokeAndGetDeletedTotal value with
846+ match cache.TryRevokeAndGetDeleted value with
847847 | ValueSome ( deleted, r) ->
848848 // r is no longer dirty since we either pull or destroy it here.
849849 dirty.Remove r |> ignore
@@ -933,7 +933,6 @@ module AdaptiveHashSetImplementation =
933933 let r = input.GetReader()
934934 do r.Tag <- " Input"
935935
936- let mutable initial = true
937936 let cache = DefaultDictionary.create< aval< 'T>, 'T>()
938937
939938 member x.Invoke ( token : AdaptiveToken , m : aval < 'T >) =
@@ -997,21 +996,24 @@ module AdaptiveHashSetImplementation =
997996
998997
999998 member x.Revoke ( v : 'A , dirty : System.Collections.Generic.HashSet < _ >) =
1000- let m = mapping.Revoke v
1001-
1002- match cache.TryGetValue m with
1003- | ( true , r) ->
1004- let struct ( cnt , v ) = r.Value
1005- if cnt = 1 then
1006- cache.Remove m |> ignore
1007- dirty.Remove m |> ignore
1008- lock m ( fun () -> m.Outputs.Remove x |> ignore )
1009- v
1010- else
1011- r.Value <- ( cnt - 1 , v)
1012- v
1013- | _ ->
999+ match mapping.TryRevoke v with
1000+ | ValueSome m ->
1001+ match cache.TryGetValue m with
1002+ | ( true , r) ->
1003+ let struct ( cnt , v ) = r.Value
1004+ if cnt = 1 then
1005+ cache.Remove m |> ignore
1006+ dirty.Remove m |> ignore
1007+ lock m ( fun () -> m.Outputs.Remove x |> ignore )
1008+ v
1009+ else
1010+ r.Value <- ( cnt - 1 , v)
1011+ v
1012+ | _ ->
1013+ failwith " [ASet] cannot remove unknown object"
1014+ | ValueNone ->
10141015 failwith " [ASet] cannot remove unknown object"
1016+
10151017
10161018 override x.Compute ( token , dirty ) =
10171019 let mutable deltas =
@@ -1072,7 +1074,7 @@ module AdaptiveHashSetImplementation =
10721074 None, None
10731075
10741076 member x.Revoke ( v : 'A ) =
1075- let m = f.Revoke v
1077+ let m = f.RevokeUnsafe v
10761078 match cache.TryGetValue m with
10771079 | ( true , r) ->
10781080 let struct ( rc , v ) = r.Value
@@ -1205,7 +1207,7 @@ module AdaptiveHashSetImplementation =
12051207 let struct ( first , other ) = pp
12061208 match state.TryGetValue first with
12071209 | ( true , x) ->
1208- let struct ( v , p ) = x
1210+ let struct ( _v , p ) = x
12091211 if pNew <> p then
12101212 state.[ first] <- ( d, pNew)
12111213 if pNew then
@@ -1219,7 +1221,7 @@ module AdaptiveHashSetImplementation =
12191221 for m in other do
12201222 match state.TryGetValue m with
12211223 | ( true , x) ->
1222- let struct ( v , p ) = x
1224+ let struct ( _v , p ) = x
12231225 if pNew <> p then
12241226 state.[ m] <- ( d, pNew)
12251227 if pNew then
0 commit comments