GithubHelp home page GithubHelp logo

poliset / kts.actorslite Goto Github PK

View Code? Open in Web Editor NEW

This project forked from brannonking/kts.actorslite

0.0 2.0 0.0 72 KB

This is a small library that supports various types of asynchronous methods in .NET. It is similar in purpose to TPL Dataflow.

License: MIT License

C# 100.00%

kts.actorslite's Introduction

Kts.Actors

This is a small library that supports various types of asynchronous methods in .NET. It exists in part because I was dissatisfied with the functionality available in the ActionBlock class that comes with the TPL Dataflow library.

This library uses the term "actor" because of Ruby; more specifically, Bernhardt's video Boundaries. It's more like "workers", though. They are queues of functions/methods to be executed.

Library Worker Types:

Most Recent: finish executing the current method and then skip to the method most recently pushed into the queue. This feature is not available in TPL Dataflow (that I can see).

Ordered: run all methods pushed on to the queue in order.

Periodic: run all methods in order but only process them every so often.

Unordered: pass the method straight onto the thread pool. Execution order is not guaranteed.

Sync: in the name of the class means execute it on the thread that calls it (immediately).

Example:

class ExampleClass
{
	private struct CriticalParams
	{
		public int Key;
		public string Value;
	}

	public ExampleClass()
	{
		_criticalMethod = new MostRecentAsyncActor<CriticalParams>(cp => 
		{
			Console.WriteLine(cp.Key + " = " + cp.Value);
		});
	}

	private readonly MostRecentAsyncActor<CriticalParams> _criticalMethod;

	public async void PrintAndSkipSomeIfTheyComeToFast(int key, string value)
	{
		await _criticalMethod.Push(new CriticalParams { Key = key, Value = value });
	}
}

What I want is the ability to do some aspect-oriented programming with this library. I'd like to decorate a method with something like [MostRecentWorker] and have it insert my actor automatically. This can be done with PostSharp presently. I'll keep an eye on Roslyn's AOP abilities as well.

Schedulers:

The library includes TaskScheduler implementaitions to match the actors. They are usefull for resolving situtions where Task.Run gives you out-of-order execution problems.

kts.actorslite's People

Contributors

brannonking avatar

Watchers

James Cloos avatar Ravi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.