Skip to content

oxffaa/lfe

Repository files navigation

codecov Build and test

Oxffaa.LFE

LFE(lock-free extensions) is a library that contains two thread-safe and same time lock-free collections for patterns "multiple producers one consumer" and handling some data parallel.

InputBox or multiple producers to one consumer

Initialize the box and share reference between producers and the consumer:

var box = new InputBox<int>();

A producer can looks like:

var val = ReadValue();
while (!box.TryAdd(val)){}

A consumer can looks like:

var values = box.TakeAll()
HandleValues(values);

OutputBox or handling some data parallel

Initialize the box with data for handling:

var box = new OutputBox(someData);

Spawn several workers like that:

while (box.HasItems)
{
    if (box.TryTake(out var item))
        HandleItem(item);
}

About

LFE(lock-free extensions) is a library that contains two thread-safe and same time lock-free collections for patterns "multiple producers one consumer" and "one producer multiple consumers".

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages