Kelson.Common

Collection of packages published under the Kelson.Common namespace

View the Project on GitHub KelsonBall/Kelson.Common

Actor < T >

The Actor Pattern is a parallel programming pattern where a thread or analogous construct is given complete ownership of a mutable resource, so that the resource cannot be mutated from multiple threads.

This actor type is a minimum-viable-implementation that leverages the Task Parallel Library for simplicity and is not tested or designed for high throughput.

Example

// using Kelson.Common.Async;

var myActor = new Actor(new List<int>());

await myActor.Do(list => list.Add(1));

await myActor.Do(list => Console.WriteLine(list.FirstOrDefault()));
> 1

Home