Skip to content

Commit

Permalink
Fix race condition with compact buffers and pending sets
Browse files Browse the repository at this point in the history
See: 6a5c280
  • Loading branch information
hyazinthh committed Jan 23, 2025
1 parent 85bfea2 commit e854719
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,19 @@ module internal CompactBufferImplementation =
let mutable currentIndex = index

member x.Write(token : AdaptiveToken) =
x.EvaluateIfNeeded token () (fun token ->
let offset = nativeint currentIndex * elementSize
let value = evaluate.Invoke(token, input)
buffer.Write(value, offset)
)
if currentIndex >= 0 then
x.EvaluateIfNeeded token () (fun token ->
let offset = nativeint currentIndex * elementSize
let value = evaluate.Invoke(token, input)
buffer.Write(value, offset)
)

member x.SetIndex(index : int) =
currentIndex <- index
x.MarkOutdated()

member x.Dispose() =
currentIndex <- -1
x.Outputs.Clear()

interface IDisposable with
Expand Down Expand Up @@ -176,8 +178,7 @@ module internal CompactBufferImplementation =
override x.InputChangedObject(_, object) =
match object with
| :? Writer<'Key, 'Value> as w -> pending.Add w |> ignore
| _ ->
()
| _ -> ()

override x.Update(token : AdaptiveToken) =
for w in pending.GetAndClear() do
Expand Down
3 changes: 1 addition & 2 deletions src/Aardvark.Rendering/Resources/Adaptive/ManagedBuffer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,7 @@ module internal ManagedBufferImplementation =
override x.InputChangedObject(_, object) =
match object with
| :? AbstractWriter as writer -> pending.Add writer |> ignore
| _ ->
()
| _ -> ()

interface IManagedBuffer<'T> with
member x.ElementType = typeof<'T>
Expand Down

0 comments on commit e854719

Please sign in to comment.