Skip to content

BatchIf race condition #98

Description

@robsonj

If a batched set of changes is consumed on a different thread (UI thread in this case) from the producer (Threadpool thread) there is a race condition between the buffered changes being cleared and the consumer consuming the buffered change set, resulting in buffered changes being lost.

from BatchIf.cs...
var resume = bufferSelector.Where(shouldPause => !shouldPause)
.Subscribe(_ =>
{
paused = false;
//publish changes and clear buffer
if (buffer.Count == 0) return;
observer.OnNext(new ChangeSet<TObject, TKey>(buffer));
buffer.Clear(); <-- Race between this and the OnNext being consumed

//kill off timeout if required
timeoutSubscriber.Disposable = Disposable.Empty;
});

I am working on a fix for this

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions